Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
kevin940726 commentedJul 31, 2020
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 withcurrentTime
or now. which contains seconds like2020-07-31T06:45:35
.45
to46
, andblur
the input.changeDate
updates state with zeroed seconds (2020-07-31T06:46:00
)onChange
is triggered with non-zeroed seconds (2020-07-31T06:46:35
)<TimePicker>
re-renders using the new state as the new date06
to07
.changeDate
triggered, and because state was updated with zeroed seconds,newDate
now 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: