-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
DateTime: Create TimeInput component and integrate into TimePicker #60613
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @bogiii! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @bogiii. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patience here! Nice refactor, and thank you for adding tests. I did a first-pass review and wrote some comments.
Have you looked into the e2e failures? They seem relevant.
Hmmm, it's strange. I've run the tests locally multiple times and passed without any problem. |
With a new TimeInput component, the hours value is in 24 hours format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the follow up!
There are a few more details that need to be sorted out before shipping this publicly, but since this PR is big and has been running long, I'd like to merge this now as a WIP component so @WordPress/gutenberg-components and others (like for #61163) can iterate on it.
I went ahead and pushed two big tweaks, which I'd like you to review in case I'm missing something:
- Simplify
minutesProps
passing (58b60be) — The idea here is to pass on all props, not juststep
, adhering to the "open/closed" pattern. - Simplify controlled/uncontrolled logic (fbf1458) — My intent here is twofold. First, to cut down on some
useEffect
usage that seemed avoidable. Second, to use theuseControlledValue
hook to simplify the handling of controlled/uncontrolled usage modes. Here, we add adefaultValue
prop for the uncontrolled pattern.
Everything else looks good, so I'm ready to merge if you're ok with my changes. Let me know if you find any issues!
Co-authored-by: Lena Morita <lena@jaguchi.com>
Hey @mirka, Thanks for the help. I reviewed your changes/suggestions and all looks good! I'm happy to see it merge. 👍 |
Thank you for the great work and collaboration here, @bogiii 🚀 I'll push through the remaining pieces to make this publicly available. Planned tasks before public ship
|
Congratulations on your first merged pull request, @bogiii! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
…ordPress#60613) * Move reducer util func to the upper level of utils * Move from12hTo24h util func to the upper level of utils * Extract validation logic into separate function * Add from24hTo12h util method * Create initial version of TimeInput component * Support two way data binding of the hours and minutes props * Add pad start zero to the hours and minutes values * Add TimeInput story * Fix two way binding edge cases and optimize onChange triggers * Remove unnecesarry Fieldset wrapper and label * Add TimeInput change args type * Integrate TimeInput into TimePicker component * Fix edge case of handling day period * Get proper hours format from the time picker component With a new TimeInput component, the hours value is in 24 hours format. * Add TimeInput unit tests * Update default story to reflect the component defaults * Simplify passing callback function * Test: update element selectors * Add todo comment * Null-ing storybook value props * Replace minutesStep with minutesProps prop * Update time-input component entry props * Don't trigger onChange event if the entry value is updated * Simplify minutesProps passing * Simplify controlled/uncontrolled logic * Set to WIP status * Add changelog * Update test description Co-authored-by: Lena Morita <lena@jaguchi.com> --------- Unlinked contributors: bogiii. Co-authored-by: mirka <0mirka00@git.wordpress.org>
Not yet documented. WordPress/gutenberg#60613
What?
TimeInput
componentTimeInput
intoTimePicker
componentWhy?
Before these changes, there was no option to use the simple time input component.
How?
Here are more details: #52734
Testing Instructions
http://localhost:50240/?path=/docs/components-timeinput--docs
--
http://localhost:50240/?path=/docs/components-timepicker--docs
Unit tests: Good old unit tests found a bug, which is resolved. ✅
Testing Instructions for Keyboard
Screenshots or screencast
✍️ Dev Note
TimePicker: Time input can be used in isolation
The time input of the
TimePicker
component can now be used in isolation as<TimePicker.TimeInput />
. In this case, thevalue
will be passed as an object in 24-hour format ({ hours: number, minutes: number }
).