Skip to content

[@mantine/core] PhoneInput: Omit the dial code from value when international is false - #9581

Open
sernstberger wants to merge 1 commit into
mantinedev:masterfrom
sernstberger:phone-input-national-value
Open

sernstberger wants to merge 1 commit into
mantinedev:masterfrom
sernstberger:phone-input-national-value

Conversation

@sernstberger

Copy link
Copy Markdown
Contributor

Fixes #9579.

Problem

With international={false} the input hides the dial code, but value and onChange still include it ("+12025551234"). Apps that take domestic numbers have to strip it on every change and add it back to every value.

Changes

  • With international={false}, onChange emits national digits ("2025551234"); the country stays in details.country.
  • value/defaultValue accept national digits in that mode. Values that start with + are still accepted, so existing stored values keep working.
  • Internal state is unchanged (still +dialCode…); conversion happens only at the value/onChange boundary. international={true} (default) is untouched.

Note

This changes the emitted value for existing international={false} users, so 10 existing assertions were updated. If you'd rather keep the current output, I can make it opt-in (e.g. valueFormat="national") instead.

Validation

  • npm run jest packages/@mantine/core/src/components/PhoneInput: 317 passed
  • Also checked by hand: a controlled national value starting with a dial-code-like prefix (20…, 44…) stays on the selected country, digit-by-digit typing, clearing, extension round trip, country switch, and a +44… value set by the parent.
  • oxlint, format, build, typecheck: pass (the only typecheck error, in HomePageSponsors.tsx, is also on master)

🤖 Generated with Claude Code

…ational is false (mantinedev#9579)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

[@mantine/core] PhoneInput: international={false} still puts the dial code in value

1 participant