Skip to content

Forms: add time field #44272

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open

Forms: add time field #44272

wants to merge 3 commits into from

Conversation

simison
Copy link
Member

@simison simison commented Jul 10, 2025

Resolves FORMS-18

Adds as a beta block, so this is safe to merge as it won't show up to customers yet.

Uses browser native time input for starters. In a follow-up we might either add another style variation, explore styling the time field better by default, or override it with more custom picker like we do for date field.

image

Proposed changes:

  • Adds time field as a beta block

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?

Testing instructions:

// Enable WP.com beta blocks
// https://github.com/Automattic/jetpack/blob/c903a93a1db5f44ff809bd25e9392b7dca45e079/projects/plugins/jetpack/extensions/README.md#beta-extensions
define('JETPACK_BLOCKS_VARIATION', 'beta'); // beta | experimental

Then add "time" field to your form.

@simison simison added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress [Package] Forms labels Jul 10, 2025
Copy link
Contributor

github-actions bot commented Jul 10, 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-time-field branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/forms-time-field

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

'jetpack/field-number',
'jetpack/field-date',
'jetpack/field-time',
'jetpack/field-url',
Copy link
Member Author

Choose a reason for hiding this comment

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

Alphabetic order

@github-actions github-actions bot added [Block] AI Assistant [Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Docs labels Jul 10, 2025
Copy link
Contributor

github-actions bot commented Jul 10, 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: August 5, 2025
    • Code freeze: August 4, 2025

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

@@ -21,12 +21,13 @@ const settings = {
'jetpack/field-multiple-choice',
'jetpack/field-name',
'jetpack/field-number',
'jetpack/field-rating',
Copy link
Member Author

Choose a reason for hiding this comment

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

Alphabetic order

@simison simison marked this pull request as ready for review July 10, 2025 15:52
Copy link

jp-launch-control bot commented Jul 10, 2025

Code Coverage Summary

Coverage changed in 5 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-contact-form-field.php 602/1037 (58.05%) -0.52% 10 💔
projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php 282/398 (70.85%) -1.27% 7 💔
projects/packages/forms/src/blocks/input/edit.js 0/29 (0.00%) 0.00% 3 ❤️‍🩹
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 424/1182 (35.87%) -0.06% 2 ❤️‍🩹
projects/packages/forms/src/contact-form/class-contact-form.php 595/1068 (55.71%) -0.06% 2 ❤️‍🩹

3 files are newly checked for coverage.

File Coverage
projects/packages/forms/src/blocks/field-time/edit.js 0/2 (0.00%) 💔
projects/packages/forms/src/blocks/field-time/index.js 0/2 (0.00%) 💔
projects/packages/forms/src/blocks/field-time/save.js 0/2 (0.00%) 💔

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@simison simison requested review from ilonagl and a team July 10, 2025 16:13
@simison simison added [Status] Needs Review This PR is ready for review. I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. and removed [Status] In Progress labels Jul 10, 2025
@@ -689,7 +696,7 @@ public function render_input_field( $type, $id, $value, $class, $placeholder, $r
}
}

// this is a hack for Firefox to prevent users from falsly entering a something other then a number into a number field.
// this is a hack for Firefox to prevent users from falsely entering a something other than a number into a number field.
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated typo fix

@@ -1447,7 +1454,7 @@ public function render_select_field( $id, $label, $value, $class, $required, $re
}

/**
* Return the HTML for the email field.
* Return the HTML for the date field.
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated typo fix

@simison simison force-pushed the add/forms-time-field branch from d1e535e to b62ff5a Compare July 11, 2025 20:11
ilonagl
ilonagl previously approved these changes Jul 14, 2025
Copy link

@ilonagl ilonagl left a comment

Choose a reason for hiding this comment

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

Yay! I am glad we have this functionality.

It looks a bit odd to have it as a wide-input, but it's not a blocker for release.

Q: do we plan to offer any settings with this?

@ilonagl
Copy link

ilonagl commented Jul 14, 2025

Some things we could improve (video walkthrough below (I'm using Arc browser)):

  • Currently, users might assume that clicking on the left-hand placeholders will open a time dropdown (in both the editor and front-end). While I understand these fields are for time input, this isn’t immediately clear. The dropdown only appears when clicking the clock icon, which could be mistaken for a decorative element. Can we make this interaction more intuitive?
  • On the front-end, the input fields appear very small—this might be a browser-specific issue, but it's worth checking.
  • Should we consider displaying timezone information? Time input can be confusing without clear timezone context, and this could lead to inconsistencies.
Time_picker_PR.mp4

@dhasilva
Copy link
Contributor

I think it is best not to use the time input type, as its UI depends heavily on the browser. On Firefox it seems to not be possible to remove AM/PM:

Screenshot from 2025-07-14 16-30-42

I was looking for a solution to this and found this implementation by Mantine where they use two or more separate text inputs, giving them a control on the input that is not possible with the time input.

@simison
Copy link
Member Author

simison commented Jul 15, 2025

It looks a bit odd to have it as a wide-input, but it's not a blocker for release.

Yep, agreed — we'll likely have a similar problem with other fields like number and some future address fields like zip code where we need to rethink how setting width works on fields.

Agreed on UX notes; I noted the same things in the issue earlier as well FORMS-18. I think what we'll do is that try preserve the native input as "style variation" as something site owners can choose to use, but that the default UX is more opinionated.

Since this is behind feature flag, I'll merge regardless, and then we can iterate.

@simison simison force-pushed the add/forms-time-field branch from e7a6ebf to 84f2342 Compare July 17, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] AI Assistant [Block] Contact Form Form block (also see Contact Form label) Docs [Feature] Contact Form I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Needs Review This PR is ready for review. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants