Skip to content

Conversation

CGastrell
Copy link
Contributor

Second attempt after reverted #45018

Phone field with country selector, second iteration.

Proposed changes:

This PR implements a searchable dropdown for the country selector on the phone field.

  • opens and scrolls to selected
  • search as you type
  • hitting "Enter" selects the first country on the filtered list
  • changes when international phone number is typed on sibling input

Working on the editor:

Screen.Recording.2025-09-05.at.16.14.53.mov

Working on the frontend:

Screen.Recording.2025-09-05.at.16.16.01.mov

NOTE: the default country setting on the inspector sidebar can remain as a secondary way of setting it or we can remove it all along. It doesn't look as nice, but as a setting it also makes sense to leave it there.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

None

Does this pull request change what data or activity we track or use?

No

Testing instructions:

Test:

  • phone number validation, use different countries and inputs
  • special note on the editor: the labels have been rolled back to just flag and prefix (trunk) while adding a more readable default country selection on the inspector sidebar
  • test dropdown search and navigation, double check phone number validation still makes sense after changing

@CGastrell CGastrell self-assigned this Sep 9, 2025
@CGastrell CGastrell added [Status] In Progress [Type] Task [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Package] Forms Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR labels Sep 9, 2025
Copy link
Contributor

github-actions bot commented Sep 9, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/forms-country-combobox branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/forms-country-combobox

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Sep 9, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 7, 2025
    • Code freeze: October 6, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link

jp-launch-control bot commented Sep 9, 2025

Code Coverage Summary

Coverage changed in 6 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/modules/field-phone/view.js 0/115 (0.00%) 0.00% 68 💔
projects/packages/forms/src/blocks/input-phone/edit.js 0/29 (0.00%) 0.00% 13 💔
projects/packages/forms/src/blocks/field-telephone/edit.js 0/25 (0.00%) 0.00% 3 ❤️‍🩹
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 412/1293 (31.86%) -0.05% 2 ❤️‍🩹
projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php 385/590 (65.25%) 0.06% 0 💚

2 files are newly checked for coverage.

File Coverage
projects/packages/forms/src/blocks/field-telephone/country-names-translated.js 0/3 (0.00%) 💔
projects/packages/forms/src/blocks/shared/components/searchable-combobox.js 0/106 (0.00%) 💔

Full summary · PHP report · JS report

Coverage check overridden by Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR .

@CGastrell CGastrell merged commit ad39a2a into trunk Sep 10, 2025
67 checks passed
@CGastrell CGastrell deleted the add/forms-country-combobox branch September 10, 2025 13:26
@github-actions github-actions bot added this to the jetpack/15.1 milestone Sep 10, 2025
CGastrell added a commit that referenced this pull request Sep 10, 2025
enejb pushed a commit that referenced this pull request Sep 25, 2025
* adapt process to use two letter country code, derive state from it

* remove debugging code

* remove field-phone registration and handlers

* deprovision default when not using country selector on phone field

* cleanup useless code

* use the right field type for international phone number: phone

* remove field-phone registration and handlers

* temp, working forwards

* migrating to interactivity, wip

* fully working, needs cleanup and styling

* clean up code and styles

* switch to probe styles specific to background colors

* fix some failing styles

* use new initialization and dom listener

* remove old actions, use more consistent naming

* add arrow navigation for dropdown

* update test after new markup

* show country toggle on toolbar

* forgotten context consumer declaration

* poc: use just flag and trunk on block, provide more complete default country selection on inspector controls

* fix searchterm being case sensitive

* scroll country list to top when searching

* allow arrow key navigation and selection even when there is no search term

* arrow key navigation selects and scrolls to country

* use pseudo element for down arrow, fix a couple of inconsistent styles

* fix indentation

* remove unused styling

* make phone input look better with animated and outlined styles

* minor style/class fixes

* changelog

* split combobox to shared component, add handlers

* add navigation to combobox on editor

* make it a bit more agnostic

* allow enter to select the first option if the user has performed a search

* address PR comments

* inherit background color so input background is honored, but it's tricky, needs testing

* adjust colors to inherit from current

* address more PR comments

* need to rebuild css class names as they come with 'class=' attached, including quotes

* fix test for phone input

* use provided styles for dropdown

* address bug with calculated probe styles: use browser default 1.2 instead of 'normal'

* address width and positioning issues

* fix styles colliding with defaults, use presets for color highlight

* use fallback color as it's more reliable than the detected background

* change down arrow, use svg instead of pseudo element

* use detected radius style when possible

* fix animated and outlined styles on combobox

* use safe background color to avoid falling into transparent

* inherit styles from block props

* fix some quirks on editor styles to match frontend

* fix @SInCE docblock for next version

* add Jetpack changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Contact Form Form block (also see Contact Form label) Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Feature] Contact Form [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [Type] Task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant