Skip to content

[Bug]: Country Code Resets to Empty String After Phone Number Update #181

@jmargielewski

Description

@jmargielewski

Bug Report: Country Code Resets to Empty String After Phone Number Update

Description

When selecting certain countries (notably US/GB), the countryCode in MuiTelInputInfo resets to an empty string after updating the phone number, despite initially being set correctly.

Steps to Reproduce

  1. Initialize MuiTelInput with any default country
  2. Select UK (or other affected countries) from the country selector
  3. Enter a phone number
  4. Observe the countryCode in the onChange handler
<MuiTelInput
  onChange={(value, info) => {
    console.log('Country Code:', info.countryCode); // Initially 'GB', then empty string
  }}
/>

Expected Behavior

  • The countryCode should remain consistent ('GB' for UK) throughout the component's lifecycle
  • The country code should not reset to an empty string after phone number updates

Actual Behavior

  • The countryCode is initially set correctly ('GB' for UK)
  • After updating the phone number, the countryCode becomes an empty string
  • This causes UI flickering and inconsistencies in country code display

Environment

  • Library Version: 9.0.0
  • React Version: 18.3.1

Impact

  • UI flickering when country code is displayed
  • Inconsistent country code tracking
  • Potential issues with form validation or country-specific logic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions