Forms: Add Native browser date picker style
This PR adds the native date picker style when choosing the date input.
Fixes https://github.com/Automattic/jetpack/issues/41811
Before:
After:
Things that are a bit odd with this PR. Placeholders. the native date picker doesn't support placeholders. We could hack with JS but wanted to discuss it first.
@Automattic/zap Any ideas how this should work? Here are some possible solutions offered in stackoverflow. https://stackoverflow.com/questions/20321202/not-showing-placeholder-for-input-type-date-field.
We could also just remove the placeholder input .
One thing to note is that the new date input normalizes formats the date to YYYY-MM-DD when submitting the form.
Proposed changes:
- Adds the date picker as a style option.
- Removed the date format as a choice from the date picker because date input doesn't have a format option.
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
Does this pull request change what data or activity we track or use?
no
Testing instructions:
- Load this PR and navigate to the block editor.
- Add the date picker. Choose the "native browser" date picker style.
- Does it work as expected in the editor?
- Does it work as expected on the front end as well?
Thank you for your PR!
When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
- :white_check_mark: Include a description of your PR changes.
- :white_check_mark: Add a "[Status]" label (In Progress, Needs Review, ...).
- :red_circle: Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
- :white_check_mark: Add testing instructions.
- :white_check_mark: Specify whether this PR includes any changes to data or privacy.
- :white_check_mark: 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 :robot:
Follow this PR Review Process:
- Ensure all required checks appearing at the bottom of this PR are passing.
- Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
- You can use GitHub's Reviewers functionality to request a review.
- 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: April 1, 2025
- Code freeze: March 30, 2025
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.
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/date-native-picker-variantbranch. - To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/date-native-picker-variant
Interested in more tips and information?
- In your local development environment, use the
jetpack rsynccommand 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
Code Coverage Summary
Coverage changed in 2 files.
| File | Coverage | Δ% | Δ Uncovered |
|---|---|---|---|
| projects/packages/forms/src/blocks/contact-form/components/jetpack-field-datepicker.js | 0/21 (0.00%) | 0.00% | 4 💔 |
| projects/packages/forms/src/contact-form/class-contact-form-field.php | 354/523 (67.69%) | 0.50% | 0 💚 |
Full summary · PHP report · JS report
If appropriate, add one of these labels to override the failing coverage check: https://github.com/Automattic/jetpack/labels/Covered%20by%20non-unit%20tests https://github.com/Automattic/jetpack/labels/Coverage%20tests%20to%20be%20added%20later https://github.com/Automattic/jetpack/labels/I%20don%27t%20care%20about%20code%20coverage%20for%20this%20PR
Things that are a bit odd with this PR. Placeholders. the native date picker doesn't support placeholders. We could hack with JS but wanted to discuss it first.
Let's just leave out the placeholder support for now when native style is active. Adding something custom is endless whack-a-mole to keep styling consistent and tends to get onto way of themers who try to rely on simple ::placeholder CSS pseudo selector.
Let's use just "Browser" as style name to make sure the copy shows up entirely.
This PR has been marked as stale. This happened because:
- It has been inactive for the past 3 months.
- It hasn’t been labeled `[Pri] BLOCKER`, `[Pri] High`, etc.
If this PR is still useful, please do a [trunk merge or rebase](https://github.com/Automattic/jetpack/blob/trunk/docs/git-workflow.md#keeping-your-branch-up-to-date) and otherwise make sure it's up to date and has clear testing instructions. You may also want to ping possible reviewers in case they've forgotten about it. Please close this PR if you think it's not valid anymore — if you do, please add a brief explanation.
If the PR is not updated (or at least commented on) in another month, it will be automatically closed.
This PR has been automatically closed as it has not been updated in some time. If you want to resume work on the PR, feel free to restore the branch and reopen the PR.