react-calendar
react-calendar copied to clipboard
Setting the value of the calendar to undefined doesn't deselect the day that was previously selected
Before you start - checklist
- [X] I followed instructions in documentation written for my React-Calendar version
- [X] I have checked if this bug is not already reported
Description
I set the value to a certain date and that day turns blue. If I then set the value back to undefined, the day is still blue.
Steps to reproduce
- Set the value prop to a day.
- Set the value prop to undefined.
- See how the day that was set in step 1 is still blue.
Expected behavior
The blue color should disappear if no date is selected.
Actual behavior
The blue color is still there as if there was a date selected, but the value is undefined so there shouldn't be any.
Additional information
No response
Environment
- React-Calendar version: 4.8.0
- React version: 18.2.0
@santiagopuentep If you set the value to null it will work as expected.
@santiagopuentep If you set the value to null it will work as expected.
It worked. Thanks! It still looks like a bug so I'll leave the issue opened.
It doesen't work for me. In mode allowPartialRange=true, if selected just a begin of date ranges, when I want clear values, I get setValues(null), but the blue color is still there. If selected both of values date range, clearing (setValues(null)) is working. React-Calendar version: 4.8.0 React version: 18.2.0
@jul0706 Yes, I have met that bug too. But it doesn't seem to be related to allowPartialRange=true, it also happen with selectRange only. I did investigate and it seems to come from that line: https://github.com/wojtekmaj/react-calendar/blob/v3.0.0/src/Calendar.jsx#L176 I didn't manage to fix it. From what I understand the Calendar is holding a "state" value internally.
I made a code sandbox to reproduce the bug. Code sanbox
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.
This issue was closed because it has been stalled for 14 days with no activity.
This is still an issue, I'm able to workaround by setting a key prop on the calendar but that feels dirty. Any scope to pick this up and fix? Or I can take a look at some point.