feat(PhoneNumberInput): add shouldDisplayCountryNames prop#3746
Open
pdrmdrs wants to merge 6 commits into
Open
feat(PhoneNumberInput): add shouldDisplayCountryNames prop#3746pdrmdrs wants to merge 6 commits into
pdrmdrs wants to merge 6 commits into
Conversation
Allow opting out of Intl.DisplayNames localization so the country selector can show calling codes from countryCode.options directly. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Skip Intl.DisplayNames localization by default so existing integrations are not affected by server/client label mismatches. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep existing localized country name behavior as the default. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 3637a20 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
Size Change: +66 B (+0.01%) Total Size: 836 kB 📦 View Changed
ℹ️ View Unchanged
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3746 +/- ##
=======================================
Coverage 93.51% 93.52%
=======================================
Files 201 201
Lines 4562 4568 +6
Branches 1790 1788 -2
=======================================
+ Hits 4266 4272 +6
Misses 267 267
Partials 29 29
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shouldDisplayCountryNamesprop toPhoneNumberInput(defaults totrue, preserving current behavior).true, country selector labels continue to useIntl.DisplayNamesfor localized country names (e.g.Canada (+1)).false, labels use the calling codes fromcountryCode.optionsdirectly (e.g.+1,+49), skippingIntl.DisplayNamesentirely.This lets consumers choose whether the country code selector displays localized country names or calling codes only.
Motivation
Intl.DisplayNamescan return different labels on the server and client for the same region code, which causes hydration mismatches in Next.js applications. For example, with Node.js 22.22.2 and Chrome 149.0.0.0,FK(+500) resolves toFalkland Islandson the server andFalkland Islands (Islas Malvinas)on the client.Setting
shouldDisplayCountryNames={false}avoids this by not callingIntl.DisplayNamesfor selector labels.A follow-up PR on the website project will describe the issue and integration in more detail.
Test plan
mapCountryCodeOptionswithshouldDisplayCountryNames={false}WithoutCountryNamesstory)Made with Cursor