Skip to content
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

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

Open
2 tasks done
santiagopuentep opened this issue Feb 19, 2024 · 6 comments
Labels
bug Something isn't working stale

Comments

@santiagopuentep
Copy link

Before you start - checklist

  • I followed instructions in documentation written for my React-Calendar version
  • 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 santiagopuentep added the bug Something isn't working label Feb 19, 2024
@rlebascle
Copy link

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

@santiagopuentep
Copy link
Author

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

@jul0706
Copy link

jul0706 commented Feb 26, 2024

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

@rlebascle
Copy link

@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
Copy link

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

Copy link
Contributor

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 github-actions bot added the stale label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants