Skip to content

refactor(phone-input): simplify with smart country detection#258

Merged
sadmann7 merged 7 commits intomainfrom
sadman/update-phoneinput
Jan 31, 2026
Merged

refactor(phone-input): simplify with smart country detection#258
sadmann7 merged 7 commits intomainfrom
sadman/update-phoneinput

Conversation

@sadmann7
Copy link
Owner

No description provided.

Simplified the phone input component by removing complex locale detection and introducing smart, context-aware country detection based on user input behavior.

Key changes:

- Smart detection: detects country immediately when user types '+' (e.g., +1 → US), or after 10+ digits when typing raw numbers

- Removed props: locale, autoDetect, showDialCode (no longer needed)

- Always stores value in E.164 format for easy backend integration

- NANP (+1) dial code now defaults to US instead of CA

- Fixed focus ring clipping issue on Windows devices

- Improved formatting logic to properly group digits after country code

- Added userTypedPlus state to track explicit '+' input intent

Breaking changes:

- Removed autoDetect, locale, and showDialCode props

- Changed detection behavior to be always smart/contextual
More descriptive variable name that clearly indicates what it checks
Copilot AI review requested due to automatic review settings January 31, 2026 01:29
@vercel
Copy link
Contributor

vercel bot commented Jan 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
diceui Ready Ready Preview, Comment Jan 31, 2026 1:34am

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the phone-input component to replace locale-based country detection with smart automatic detection based on the entered phone number itself. The refactor removes several props (locale, autoDetect, showDialCode) and simplifies the API by automatically detecting countries from phone number patterns and formatting numbers on-the-fly.

Changes:

  • Removed locale-based automatic country detection in favor of phone number pattern-based detection
  • Added automatic phone number formatting (groups digits by 3 with spaces)
  • Removed locale, autoDetect, and showDialCode props from the API
  • Changed internal value storage to always use "+" prefix format
  • Removed the phone-input-no-auto-detect-demo example

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
docs/types/docs/phone-input.ts Removed locale, autoDetect, and showDialCode prop definitions from TypeScript types
docs/registry/registry-examples.ts Removed phone-input-no-auto-detect-demo example registration
docs/registry/default/ui/phone-input.tsx Major refactor: added detectCountryFromNumber and formatPhoneNumber functions, removed locale detection, simplified state management, changed form value format
docs/registry/default/examples/phone-input-no-auto-detect-demo.tsx Deleted example file demonstrating autoDetect=false
docs/registry/default/examples/phone-input-demo.tsx Updated to use controlled state and demonstrate the new automatic formatting
docs/registry/default/examples/phone-input-custom-countries-demo.tsx Updated defaultValue to include country code prefix
docs/content/docs/components/phone-input.mdx Removed documentation about locale detection and autoDetect feature
Various JSON files Line ending normalization (CRLF changes)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sadmann7 sadmann7 merged commit 0f4d223 into main Jan 31, 2026
8 checks passed
@sadmann7 sadmann7 deleted the sadman/update-phoneinput branch January 31, 2026 01:35
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.

2 participants