Skip to content
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

Contact form: Fix problem when inserting phone number that begins with same digits as country code #54477

Conversation

leonardost
Copy link
Contributor

@leonardost leonardost commented Jul 12, 2021

Changes proposed in this Pull Request

The phone input field in the domain contact information form has had a problem for some time (issue #25039): when a user tries to input a phone number which begins with the same digits as the selected country's international dialing code, these numbers are removed from the input. Copy and pasting also doesn't work, the initial digits are removed the same.

For example, Brazil's dial code is +55, and a valid Brazilian phone number is 55 1234-5678, 55 being a national city code. This video shows what happens when you try to input that number by typing or pasting:

Kapture.2021-07-12.at.18.11.31.mp4

This PR fixes that behavior by updating the logic of when the international dialing prefix should be removed.

Testing instructions

This component has been tweaked several times (#41783, #37603, #24870, #10447 to cite a few), so please test it thoroughly. 🙇‍♂️

Unit tests should all be passing: yarn run test-client client/components/phone-input/test, but manual testing is also appreciated. The contact information form can be reached in the checkout page when buying a domain.

  • Open the contact information form, enter phone number +555512345678 and ensure Brazil becomes the selected country. The number should be formatted like +55 55 1234-5678
  • Clear that number and while Brazil is still selected, try to enter phone number 5512345678. Ensure the 55 city code prefix is not removed.
  • Try other combinations of countries and phone numbers, for example:
    • Select Italy (dial code +39) and enter phone number 3911711711 - ensure the initial 39 remains there
    • Select India (dial code +91) and enter phone number 9100123456 - ensure the initial 91 remains there
    • Select a NANPA (North American Numbering Plan Administrator) country - the US, Canada, etc. - enter a valid phone number and ensure it is formatted correctly

Related to #25039

When a user tries to input a phone number which starts with the same
digits as the selected country's code, that initial part gets removed.
This happens for example for Brazilian (international code +55) phone
numbers: if I write 55 12345678 (55 being a valid city code), it gets
truncated into 12345678. As reported in issue #25039, this happens for
any phone number in the same situation.
@matticbot
Copy link
Contributor

matticbot commented Jul 12, 2021

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~17 bytes added 📈 [gzipped])

name            parsed_size           gzip_size
site-purchases        +61 B  (+0.0%)      +17 B  (+0.0%)
purchases             +61 B  (+0.0%)      +17 B  (+0.0%)
domains               +61 B  (+0.0%)      +17 B  (+0.0%)
checkout              +61 B  (+0.0%)      +17 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~17 bytes added 📈 [gzipped])

name                                             parsed_size           gzip_size
async-load-design-playground                           +61 B  (+0.0%)      +17 B  (+0.0%)
async-load-design                                      +61 B  (+0.0%)      +17 B  (+0.0%)
async-load-calypso-blocks-editor-checkout-modal        +61 B  (+0.0%)      +17 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@matticbot
Copy link
Contributor

This PR modifies the release build for wpcom-block-editor

To test your changes on WordPress.com, run install-plugin.sh wpcom-block-editor update/fix-problem-when-inserting-phone-number-that-begins-with-same-numbers-as-country-code on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-l4k-p2

@matticbot
Copy link
Contributor

This PR modifies the release build for notifications

To test your changes on WordPress.com, run install-plugin.sh notifications update/fix-problem-when-inserting-phone-number-that-begins-with-same-numbers-as-country-code on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-elI-p2

@matticbot
Copy link
Contributor

matticbot commented Jul 12, 2021

@matticbot
Copy link
Contributor

This PR modifies the release build for editing-toolkit

To test your changes on WordPress.com, run install-plugin.sh editing-toolkit update/fix-problem-when-inserting-phone-number-that-begins-with-same-numbers-as-country-code on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-mMA-p2

@leonardost leonardost marked this pull request as ready for review July 12, 2021 22:05
@leonardost leonardost requested a review from a team July 12, 2021 22:05
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 12, 2021
@leonardost leonardost changed the title Fix problem when inserting phone number that begins with same numbers as country code Fix problem when inserting phone number that begins with same digits as country code Jul 12, 2021
@leonardost leonardost changed the title Fix problem when inserting phone number that begins with same digits as country code Contact form: Fix problem when inserting phone number that begins with same digits as country code Jul 12, 2021
@leonardost leonardost added the [Feature Group] Emails & Domains Features related to email integrations and domain management. label Jul 12, 2021
Copy link
Contributor

@delputnam delputnam left a comment

Choose a reason for hiding this comment

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

Ok. I've reviewed this and tested it every way I can think if. It seems to work great.
Thank you for this fix and for adding the tests! 🙇

@leonardost leonardost merged commit 8ab4c5a into trunk Jul 14, 2021
@leonardost leonardost deleted the update/fix-problem-when-inserting-phone-number-that-begins-with-same-numbers-as-country-code branch July 14, 2021 18:13
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature Group] Emails & Domains Features related to email integrations and domain management.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants