Repository navigation
Fix not truncating at minutes the first time in <TimePicker> - #24305
Merged
talldan merged 1 commit intoJul 31, 2020
Merged
Conversation
kevin940726
requested review from
ajitbohra,
chrisvanpatten and
youknowriad
as code owners
July 31, 2020 07:55
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Continued from #15495.
Seems like that PR only fixes truncating at minutes the second time and beyond. When first calling
changeDate, the truncated date is saved in the Component's internal state, but not passed as a argument ofonChange.The detailed steps are as follow:
<TimePicker>initializes the date withcurrentTimeor now. which contains seconds like2020-07-31T06:45:35.45to46, andblurthe input.changeDateupdates state with zeroed seconds (2020-07-31T06:46:00)onChangeis triggered with non-zeroed seconds (2020-07-31T06:46:35)<TimePicker>re-renders using the new state as the new date06to07.changeDatetriggered, and because state was updated with zeroed seconds,newDatenow also has zeroed seconds (2020-07-31T07:46:00)Note the 4th step, the component will temporary have a non-zeroed second in the date value.
It's likely that users tend to not only update the time once, normally they would update it multiple times, that's why we didn't notice the bug before 🤔 ?
I'm also trying to refactor this component into function component. The updated implementation should not have this bug, but figured to open a bug fix PR first to get it landed. Will open another PR for the refactor.
How has this been tested?
Added unit test in
test/time.js.Also can tested in the
<PostSchedule>component. Create a new post and change the schedule time in the settings, and observe the value in devtools or React devtools.Types of changes
Bug fix
Checklist: