-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(date-picker): stabilize defaultDate behavior #13186
fix(date-picker): stabilize defaultDate behavior #13186
Conversation
* Ignore time in date objects when comparing for equality to prevent overrides * clear input values on rerender when value prop is set to prevent overrides * Add test story (to be deleted)
✅ Deploy Preview for carbon-components-react ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for carbon-elements ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
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.
Behaves as expected for me in the test storybook! 👍
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.
Working as expected! Nice work on this 🎉 ✅ 👍🏻
Closes #13058
Why
Issue here was with the introduction of
hasInput
the calendar instance is being destroyed and recreated the first time the components loads; so when a default value is set and the calendar instance was destroyed after the inputs had been populated (with the default values), it was picking up the dates both from the input fields and thedefaultDate
value, causing the flatpickr instance to behave unexpectedly.Upon fixing that, found another issue where attempting to change the date through the calendar when a defaultValue had been previously set required the user to double click on the date due to the first click being overriden by a date equality comparison that didn't evaluate to
true
due to digressing times on the date resulting from a date object being created from thedefaultValue
VS creating it from the calendar selection.Changelog
Changed
Testing / Reviewing
Test using "test" story in Datepicker in deployment
TODO