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

Disable dates, but not the navigation

Open brett-chisholm opened this issue 6 years ago • 7 comments

I have a requirement where I need to disable a date range but still have the arrow navigation functional, is this possible?

brett-chisholm avatar May 05 '20 08:05 brett-chisholm

Absolutely. Use pass a function that returns true for dates that are meant to be disabled to tileDisabled.

wojtekmaj avatar May 05 '20 09:05 wojtekmaj

Awesome, thanks! So I've got the disabled dates working, but I can no longer navigate by year using the arrows in the navigation if my available dates are within a year. Is there any way to un-disable the arrow navigation, or have it remain active regardless of what is disabled/available?

brett-chisholm avatar May 05 '20 09:05 brett-chisholm

Hmmm, not sure what you got 🤔

  • Tiles disabled using tileDisabled will not disable any navigation
  • Tiles disabled using minDate, maxDate will

wojtekmaj avatar May 11 '20 15:05 wojtekmaj

So I am currently using both tileDisabled and minDate/maxDate. I use tileDisabled to suspend slots which have already been booked, and minDate/maxDate to restrict the range which the user can be chosen from.

The problem I have is if I have a date range from 01/02/2020 to 31/01/2021 the user is restricted to navigating by month rather than being able to navigate by a whole year. Is there an option to have the navigation active at all times?

Thank you for all your hard work on this, love the component!

brett-chisholm avatar May 12 '20 08:05 brett-chisholm

Thanks for the kind words. Unfortunately Navigation blocks navigating to any view which doesn't contain a single enabled tile (enabled = not limited by min/max date).

wojtekmaj avatar May 15 '20 19:05 wojtekmaj

First all, thanks for this great component @wojtekmaj .

I have comment to make on this thread. I am trying to use this component somewhat like @brett-chisholm establishing a range of valid dates and likewise I use tileDisabled to disable invalid slots.

My comment would be, given a mindate and maxdate, tileDisabled seems to be run on dates out of this range and do it on displaying and on hiding.

yagovago2 avatar Mar 04 '21 05:03 yagovago2

tileDisabled runs on all tiles that are being rendered, same as tileClassName and tileContent.

wojtekmaj avatar Mar 10 '21 22:03 wojtekmaj