Skip to content

fix: Venezuela (+58) phone number formatting in PhoneInput component #22873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

naaa760
Copy link

@naaa760 naaa760 commented Aug 2, 2025

What does this PR do?

  • This PR fixes the phone number formatting issue for Venezuela (+58) country code in the PhoneInput component. The current implementation incorrectly formats Venezuelan phone numbers with extra spaces, while the expected format should have a space after the first 3 digits followed by 7 consecutive digits.

Close: #22871

  • Fixes phone number formatting for Venezuela (+58) country code
  • Ensures correct format: +58 XXX XXXXXXX instead of +58 XXX XXX XXX X

Visual Demo (For contributors especially)

Before (Incorrect Format):

+58 424 245 732 1

After (Correct Format):

+58 424 2457231
  • The bug was visible in the booking form where users selecting Venezuela (+58) would see phone numbers formatted with extra spaces, making them appear as +58 XXX XXX XXX X instead of the expected +58 XXX XXXXXXX format.

How should this be tested?

Test Configuration:

  • No special environment variables required
  • Test with any Venezuelan phone number (+58 country code)

Test Steps:

  1. Navigate to any booking form with phone input field
  2. Select Venezuela (+58) as the country
  3. Enter a Venezuelan phone number (e.g., 584242457231)
  4. Verify the number displays as +58 424 2457231 (correct format)
  5. Test with existing formatted numbers to ensure they reformat correctly

Expected Behavior:

  • Input: 584242457231 or +58 424 245 732 1
  • Output: +58 424 2457231
  • Other countries: Should remain unaffected and use their default formatting

Test Cases:

  • Basic Venezuela number: 584242457231+58 424 2457231
  • Number with existing formatting: +58 424 245 732 1+58 424 2457321
  • Partial number: 58424+58 424
  • Non-Venezuela numbers should remain unchanged

… Venezuela's specific phone number format

Integration of this formatter into both PhoneInput components via the format prop
Copy link

vercel bot commented Aug 2, 2025

@naaa760 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 2, 2025

Walkthrough

A new helper function, formatVenezuelaPhoneNumber, was introduced to format Venezuelan phone numbers (country code +58) by grouping digits in a specific pattern after the country code. This function is applied via the format prop in both the BasePhoneInput and BasePhoneInputWeb components within the PhoneInput module. For non-Venezuelan numbers, the original input remains unchanged. The changes are confined to the PhoneInput component file and affect the formatting logic for phone number inputs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Assessment against linked issues

Objective Addressed Explanation
Correct formatting of Venezuelan phone numbers with +58 country code (#22871)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4509480 and e89177d.

📒 Files selected for processing (1)
  • packages/features/components/phone-input/PhoneInput.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/features/components/phone-input/PhoneInput.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Tests / Unit
  • GitHub Check: Type check / check-types
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Aug 2, 2025
@graphite-app graphite-app bot requested a review from a team August 2, 2025 06:52
Copy link
Contributor

github-actions bot commented Aug 2, 2025

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "fix : Venezuela (+58) phone number formatting in PhoneInput component ". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@dosubot dosubot bot added ui area: UI, frontend, button, form, input 🐛 bug Something isn't working labels Aug 2, 2025
Copy link

graphite-app bot commented Aug 2, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (08/02/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (08/02/25)

1 label was added to this PR based on Keith Williams's automation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
packages/features/components/phone-input/PhoneInput.tsx (3)

75-75: Consider memoizing the format function for better performance.

The arrow function is recreated on every render. For better performance, consider extracting it to a stable reference.

+const formatFunction = (value: string, country: { iso2: string }) => 
+  formatVenezuelaPhoneNumber(value, country.iso2);

 <PhoneInput
   {...rest}
   value={value ? value.trim().replace(/^\+?/, "+") : undefined}
   enableSearch
   disableSearchIcon
   country={defaultCountry}
-  format={(value, country) => formatVenezuelaPhoneNumber(value, country)}
+  format={formatFunction}

123-123: Apply the same performance optimization as BasePhoneInput.

For consistency with the BasePhoneInput component, consider using the same memoized format function approach here.

 <PhoneInput
   {...rest}
   value={value ? value.trim().replace(/^\+?/, "+") : undefined}
   country={value ? undefined : defaultCountry}
   enableSearch
   disableSearchIcon
-  format={(value, country) => formatVenezuelaPhoneNumber(value, country)}
+  format={formatFunction}

24-50: Add comprehensive unit tests for the new formatting function.

The new formatVenezuelaPhoneNumber function handles critical user-facing functionality but lacks unit tests. This could lead to regressions or undetected edge case failures.

Key test scenarios needed:

  • Venezuelan numbers with correct formatting
  • Venezuelan numbers with incorrect existing formatting
  • Partial Venezuelan numbers
  • Non-Venezuelan numbers (should remain unchanged)
  • Edge cases (empty strings, malformed inputs)
  • Numbers with/without leading "+"

Would you like me to generate comprehensive unit tests for this function?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35a373e and 9bbb19a.

📒 Files selected for processing (1)
  • packages/features/components/phone-input/PhoneInput.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/features/components/phone-input/PhoneInput.tsx
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/components/phone-input/PhoneInput.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Detect changes
  • GitHub Check: Codacy Static Code Analysis

… Venezuela's specific phone number format

Integration of this formatter into both PhoneInput components via the format prop
@github-actions github-actions bot added the booking-page area: booking page, public booking page, booker label Aug 2, 2025
Copy link
Contributor

@Devanshusharma2005 Devanshusharma2005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typechecks and tests are failing. Could you please address them ?

@naaa760
Copy link
Author

naaa760 commented Aug 3, 2025

@Devanshusharma2005
resolve it!

// Handle edge cases
if (!value || typeof value !== 'string') return value || '';

if (country === "ve") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick thought: applying the fail-fast principle here (e.g. if (country !== 've') return value;) might help make the logic a bit cleaner by reducing nesting.

Copy link
Contributor

@Devanshusharma2005 Devanshusharma2005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tyechecks are failing. Could you please address them.
And also add a loom to show the correct changes.

@anikdhabal anikdhabal changed the title fix : Venezuela (+58) phone number formatting in PhoneInput component fix: Venezuela (+58) phone number formatting in PhoneInput component Aug 8, 2025
Copy link
Contributor

@volnei volnei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review the comments :)

@naaa760
Copy link
Author

naaa760 commented Aug 11, 2025

@volnei
I will update soon!

@kart1ka kart1ka marked this pull request as draft August 11, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
booking-page area: booking page, public booking page, booker 🐛 bug Something isn't working community Created by Linear-GitHub Sync ui area: UI, frontend, button, form, input
Projects
None yet
Development

Successfully merging this pull request may close these issues.

format bug with (+58)
4 participants