Skip to content

Use native select for address form to fix country/state value issues - #53

Merged
damianlegawiec merged 2 commits into
mainfrom
fix/address-form-selects
Mar 11, 2026
Merged

Use native select for address form to fix country/state value issues#53
damianlegawiec merged 2 commits into
mainfrom
fix/address-form-selects

Conversation

@damianlegawiec

@damianlegawiec damianlegawiec commented Mar 11, 2026

Copy link
Copy Markdown
Member

Also unified alerts in checkout

Summary by CodeRabbit

  • New Features

    • Added native select component for enhanced form controls.
  • Style

    • Checkout address forms now use native select dropdowns.
    • Error messages throughout checkout updated with improved alert styling.
    • Applied promotions display refreshed with alert-based layout and visual refinement.

@coderabbitai

coderabbitai Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@damianlegawiec has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d028ebf-08de-4cf1-964b-7ae2845d3f16

📥 Commits

Reviewing files that changed from the base of the PR and between 89b3dd8 and 3351bfb.

📒 Files selected for processing (2)
  • src/components/checkout/AddressStep.tsx
  • src/components/checkout/CouponCode.tsx

Walkthrough

The pull request migrates checkout form components from Radix UI Select components to native HTML select elements, while standardizing UI messaging patterns across multiple components using Alert-based layouts. The custom Select component is removed and replaced with a new NativeSelect component library.

Changes

Cohort / File(s) Summary
Checkout Form Migration
src/components/checkout/AddressFormFields.tsx
Replaces Select/SelectItem/SelectTrigger/SelectValue components with NativeSelect and NativeSelectOption; updates event handling from onValueChange to onChange with event.target.value; adds disabled placeholder options and loading state representation.
Checkout UI Standardization
src/components/checkout/AddressStep.tsx, src/components/checkout/CouponCode.tsx, src/components/checkout/StripePaymentForm.tsx
Updates multiple checkout components to use Alert-based layouts with icon elements (InfoIcon, CheckCircle, CircleAlert) and AlertDescription for messaging, replacing custom div structures without altering data flow or state management.
UI Component Library
src/components/ui/native-select.tsx, src/components/ui/select.tsx
Introduces new NativeSelect component module with NativeSelect, NativeSelectOption, and NativeSelectOptGroup exports supporting size variants, styling, and ChevronDownIcon decoration. Removes entire Radix UI-based Select component library (10 exported components).

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hops skip to native grounds,
Where selects find their home,
Alerts in chevron rounds,
No Radix to roam!
Cleaner forms, simpler code,
A brighter checkout road! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: replacing UI select components with native selects in the address form to fix country/state value issues, which is evident across AddressFormFields.tsx and the removal of the custom Select component.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/address-form-selects

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/components/ui/native-select.tsx (1)

10-54: Add explicit return types to the new select primitives.

These three new TSX functions are part of a shared UI surface, so it would be good to annotate their return types explicitly instead of relying on inference.

Suggested change
-function NativeSelect({
+function NativeSelect({
   className,
   size = "default",
   ...props
-}: NativeSelectProps) {
+}: NativeSelectProps): React.JSX.Element {
   return (
     <div
@@
-function NativeSelectOption({ ...props }: React.ComponentProps<"option">) {
+function NativeSelectOption({
+  ...props
+}: React.ComponentProps<"option">): React.JSX.Element {
   return <option data-slot="native-select-option" {...props} />;
 }
@@
 function NativeSelectOptGroup({
   className,
   ...props
-}: React.ComponentProps<"optgroup">) {
+}: React.ComponentProps<"optgroup">): React.JSX.Element {
   return (
     <optgroup

As per coding guidelines "Use strict TypeScript type checking; define explicit return types for functions and avoid 'any' type".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/ui/native-select.tsx` around lines 10 - 54, Add explicit
return types to the three new components: annotate NativeSelect,
NativeSelectOption, and NativeSelectOptGroup with a React component return type
(e.g., JSX.Element or React.ReactElement) in their function signatures instead
of relying on inference; update the signatures of NativeSelect({ ... }:
NativeSelectProps), NativeSelectOption({ ... }: React.ComponentProps<"option">),
and NativeSelectOptGroup({ ... }: React.ComponentProps<"optgroup">) to include
the chosen explicit return type and ensure React is imported if not already.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/checkout/AddressStep.tsx`:
- Around line 127-135: The Alert in AddressStep.tsx is using the default
role="alert" (from the Alert component) which causes the guest sign-in hint to
be announced as urgent; change the wrapper to a non-urgent role by overriding
the Alert's role prop (e.g., role="status") or replace the Alert with a neutral
wrapper so the content in AlertDescription (and the signInUrl Link) is not
announced as an urgent alert; update the Alert usage in AddressStep.tsx
accordingly.

In `@src/components/checkout/CouponCode.tsx`:
- Around line 67-86: The promotion rows use the Alert component which sets
role="alert" causing screen readers to announce persisted coupons; update the
JSX in CouponCode.tsx to use a neutral container instead (e.g., replace <Alert
key={promotion.id}>...</Alert> with a non-alert wrapper such as a styled <div>
or a Card component that preserves the same visual styles) or explicitly
override the role attribute on the wrapper to a neutral value (role="group" or
no role) so it’s not treated as an urgent announcement; keep the inner content
and handlers (promotion.id, promotion.code/promotion.name,
promotion.display_amount, handleRemove, removing) unchanged.

---

Nitpick comments:
In `@src/components/ui/native-select.tsx`:
- Around line 10-54: Add explicit return types to the three new components:
annotate NativeSelect, NativeSelectOption, and NativeSelectOptGroup with a React
component return type (e.g., JSX.Element or React.ReactElement) in their
function signatures instead of relying on inference; update the signatures of
NativeSelect({ ... }: NativeSelectProps), NativeSelectOption({ ... }:
React.ComponentProps<"option">), and NativeSelectOptGroup({ ... }:
React.ComponentProps<"optgroup">) to include the chosen explicit return type and
ensure React is imported if not already.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3337847f-d2d8-400c-806b-4ed5b74b9c5d

📥 Commits

Reviewing files that changed from the base of the PR and between a99ee7b and 89b3dd8.

📒 Files selected for processing (6)
  • src/components/checkout/AddressFormFields.tsx
  • src/components/checkout/AddressStep.tsx
  • src/components/checkout/CouponCode.tsx
  • src/components/checkout/StripePaymentForm.tsx
  • src/components/ui/native-select.tsx
  • src/components/ui/select.tsx
💤 Files with no reviewable changes (1)
  • src/components/ui/select.tsx

Comment thread src/components/checkout/AddressStep.tsx Outdated
Comment thread src/components/checkout/CouponCode.tsx Outdated
CodeRabbit flagged that the guest sign-in hint and applied coupon
alerts were using role="alert" (urgent), when they should be
role="status" for persistent informational content.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@damianlegawiec
damianlegawiec merged commit 231ed02 into main Mar 11, 2026
4 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 13, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant