Skip to content

Inconsistent Phone Number Formatting Across Country Codes in PhoneInput Component #24193

@sahil5343

Description

@sahil5343

Found a bug? Please fill out the sections below. 👍

Issue Summary

There is an inconsistency in phone number formatting across different country codes in the phone input component. The bug is caused by the way phone numbers are parsed and formatted using the libphonenumber-js library without enforcing a standardized formatting pattern. This leads to unpredictable spacing and grouping of numbers depending on the country code.

Steps to Reproduce

  1. Go to the phone number input field in the app (packages/features/components/phone-input/PhoneInput.tsx).
  2. Enter a phone number with a country code, e.g., +58XXXXXXXXXX.
  3. Observe the format of the number displayed.
  4. Change the country code to +1 or +44 and enter the respective number.
  5. Compare the displayed format across different country codes.

Actual Results

  • Phone numbers appear in inconsistent formats depending on the country code.
  • Some country codes add extra spacing or different grouping of digits.
  • The "+" prefix is always added, sometimes resulting in unexpected formatting.

Expected Results

  • Phone numbers should follow a consistent, standardized format regardless of the country code.
  • Ideally, the formatting should align with the E.164 standard or a uniform international format for all numbers.

Technical details

  • Files involved:
    • packages/lib/formatPhoneNumber.ts
    • packages/features/components/phone-input/PhoneInput.tsx
  • Code snippet causing the issue (from formatPhoneNumber.ts):
export const formatPhoneNumber = (phoneNumber: string) => {
  const parsedPhoneNumber = parsePhoneNumberWithError(phoneNumber);
  return parsedPhoneNumber?.isValid() ? parsedPhoneNumber.formatInternational() : phoneNumber;
};
  • The issue occurs because:

    • PhoneInput.tsx automatically adds a "+" prefix to all numbers.
    • formatPhoneNumber relies on libphonenumber-js which applies different spacing/grouping rules per country code.
    • No standardized formatting pattern is enforced.
  • Environment details:

    • Browser: [Add your browser version here]
    • Node.js version: [Add your Node.js version here]
    • No backend involvement — purely frontend formatting issue

Evidence

  • Testing performed manually by entering numbers for multiple country codes (+58, +1, +44).
  • Screenshots/videos should be attached to show the inconsistency (e.g., different spacing applied).

This bug is self-contained and limited to the phone input and formatting logic. Fixing it would significantly improve the consistency and user experience of the phone number input feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Low priorityCreated by Linear-GitHub Sync🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions