-
Notifications
You must be signed in to change notification settings - Fork 2.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
Dynamic change of state, doesn't update the calendar view #3901
Comments
Hello, I'm actually facing a similar issue! I have a slightly simpler use case, where I have a set of selectable options adjacent to a calendar that update the calendar's single date state (instead of a range). E.g. I made a sandbox forked from the one linked above to demonstrate this: https://codesandbox.io/s/react-date-pickers-forked-5j5zg4?file=/src/App.js Repoduction Steps
Additionally, an oddity I've found:
Edit: |
I've also run into a similar issue while using Here's a quick screencap showing the issue for my specific implementation: Interestingly enough, when replicating a similar setup on the playground, everything Clearly, this is an issue specific to my implementation, but it's not clear to me why. Any guidance here would be helpful. EDIT EDIT 2 |
@tabuckner any updates? My custom input also doesn't update calendar value on manual input |
same here |
When I was doing the date range picker with custom selectable ranges only used one DatePicker, I faced the same issue. Also, I made a CustomInput(docs) and CustomContainer(docs) for my DatePicker. Then, I used these for handling open state. I hope this can be useful for you. For calendar update you can give the key based on startDate to DatePicker (like
If you want that picker to close when the end date selected, you need to change onChange prop also. For example for my range change I did this const:
The if statement did the same thing shouldCloseOnSelect prop. Also, you can do the same thing for custom selectable ranges. You need to setIsCalendarOpen(false) after the setDate. I didn't try to use this handling on input or 2 different DatePicker components but at least worth to try. |
Here is the solutionI didn't want to resolve this issue in such a complex manner, but it seems like the only way, so I'm sharing it with you. To change the calendar view, you must use the changeMonth and changeYear functions available in renderCustomHeader. To convert to a custom range in the CalendarContainer, these two functions need to be stored using a ref and then passed to CalendarContainer as props for use.
|
Are there any updates on this issue? |
Describe the bug
I have made a semi range-picker using two separate date pickers, and added calendar container to the second one so that I can add some default ranged buttons to it and everything works perfect. The user can either change of dates manually, or using default ranged buttons and then click on "apply" to submit the changes.
The problem is clicking on the buttons does set the start/end states, but the calendar doesn't get updated and shows the old month.
I have replicated the problem out here...
CodeSandBox
To Reproduce
Expected behavior
After step 3, when startDate changes to January 1, 2022, and endDate --> December 30, 2022, calendars should show the correct months/years
Thanks!
The text was updated successfully, but these errors were encountered: