Skip to content

[@mantine/core] PhoneInput: Hide the country selector when only one country is available - #9582

Open
sernstberger wants to merge 1 commit into
mantinedev:masterfrom
sernstberger:phone-input-without-country-select
Open

sernstberger wants to merge 1 commit into
mantinedev:masterfrom
sernstberger:phone-input-without-country-select

Conversation

@sernstberger

Copy link
Copy Markdown
Contributor

Closes #9580.

Problem

A single-country phone input still shows the country button and dropdown, which has nothing to choose from. The only way to remove it today is passing leftSection, which replaces the button by accident and keeps its pointer events and width.

Changes

  • When onlyCountries/excludeCountries leave one country, the country button and dropdown are not rendered, and leftSection is free for the app.
  • That country is selected even without defaultCountry. Otherwise there would be no country and no way to pick one.
  • Docs section "Without country selector" with a demo (onlyCountries={['us']} + a phone icon in leftSection).

No new props. With two or more countries nothing changes.

Validation

  • npm run jest packages/@mantine/core/src/components/PhoneInput: 319 passed, including 2 new tests (the regression test for selecting the only country fails without the fix)
  • Also checked by hand: no left padding without leftSection, the dropdown stays hidden with dropdownOpened, Tab skips straight to the input, the button appears and disappears when onlyCountries changes at runtime, unknown ISO codes are ignored, and disabled/readOnly work.
  • oxlint, format, build, typecheck: pass (the only typecheck error, in HomePageSponsors.tsx, is also on master)

🤖 Generated with Claude Code

…ountry is available

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.

1 participant