-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Calendar popup state is not reset when the Date Value is set based on state change #668
Comments
Could anyone provide an input here? If this is the expected behaviour then that can be mentioned and the bug report can be closed. |
Any update on this issue? |
I just ran into this issue too. Sometimes it's possible to work around it by using a |
Yeah that is exactly how i worked around this issue although I'd prefer to avoid remounting the component itself tbh as you get the "flashy" effect. |
Sorry, I am a bit confused. Could you elaborate on this workaround please? |
Use the date you have currently set as a key for the DatePicker itself |
I just want to add that setting the key based on the selected value works fine but please don't make the same mistake I made at first. You should set the key of the calendar via calendarProps and not directly in the root props of the date picker, something like: This way only the calendar will get re-rendered, which is what we want in this scenario, instead of re-rendering the whole date picker. |
Before you start - checklist
Description
When using the library and I change the date value from external action, the value shown in the text box updates correctly. But the calendar that pops up is still on the old year and month.
I have a basic example setup in the below codesandbox
https://codesandbox.io/s/react-date-picker-xxsgjk
Steps to reproduce
Steps to reproduce using the below codesandbox
Expected behavior
The calendar should open to the same month and year as displayed in the text box
Actual behavior
The calendar opens to the previously selected month and year that was set by actually clicking on the calendar
Additional information
No response
Environment
The text was updated successfully, but these errors were encountered: