-
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
Components: Fix the timepicker, only update the values on blur #4193
Conversation
const { onChange } = this.props; | ||
const { am, date, hours } = this.state; | ||
if ( am === value ) { | ||
return; |
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.
Does this ever fire, or is it just for sanity here?
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.
It does fire when you hit the "toggled" button
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.
Ah cool, thanks for clarifying. It wasn't clear to me, and it's not covered by the tests either, so I thought to ask :-)
/** | ||
* Module Constants | ||
*/ | ||
const TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss'; |
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.
Why not just TIME_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.
The input and the output format should be the same, that's the format we have in the post object. We could use only a time format for time and date format for date but this means adding some "unnecessary" date manipulations in the parent component date-time
(extract time and date on input, and recompute the whole date on change). I think it's just for convenience.
isToggled={ am === 'AM' } | ||
onClick={ this.updateAmPm( 'AM' ) } | ||
> | ||
{ __( 'AM' ) } |
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.
Not sure if these need some translation context in general. cc @yoavf
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.
Not sure if these need some translation context in general.
I would have possibly expected context to be good here, but noting elsewhere in core it is not provided:
Going to merge this if no more concerns? |
🚢 |
closes #3661
This PR changes the behavior of the TimPicker to be able to edit it freely and do the validation and updates on blur only.
This also makes the Component API more consistent, the format of the input and output value is made consistent. (Moment is only internal while the API expects timezone-less dates)
Testing instructions