react-calendar icon indicating copy to clipboard operation
react-calendar copied to clipboard

Setting the value of the calendar to undefined doesn't deselect the day that was previously selected

Open santiagopuentep opened this issue 1 year ago • 5 comments

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

  1. Set the value prop to a day.
  2. Set the value prop to undefined.
  3. 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 avatar Feb 19 '24 13:02 santiagopuentep

@santiagopuentep If you set the value to null it will work as expected.

rlebascle avatar Feb 22 '24 14:02 rlebascle

@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.

santiagopuentep avatar Feb 22 '24 17:02 santiagopuentep

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 avatar Feb 26 '24 04:02 jul0706

@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.

rlebascle avatar Feb 26 '24 07:02 rlebascle

I made a code sandbox to reproduce the bug. Code sanbox

rlebascle avatar Feb 26 '24 14:02 rlebascle

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.

github-actions[bot] avatar May 27 '24 00:05 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Jun 10 '24 00:06 github-actions[bot]

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.

Travis-Kirton avatar Aug 13 '24 17:08 Travis-Kirton