Hacker0x01 / react-datepicker

A simple and reusable datepicker component for React
https://reactdatepicker.com/
MIT License
7.92k stars 2.23k forks source link

MonthYearPicker: Excluded/Disabled Months are able to be navigated to with keyboard #4731

Closed ryantanrk closed 1 month ago

ryantanrk commented 2 months ago

Describe the bug When a month year picker has excluded dates excludeDates, without any value selected, the date picker is able to navigate to the excluded month, but with value selected, we cannot navigate to the excluded month.

When that excluded month is selected, it throws an invalid time value error: image

To Reproduce Steps to reproduce the behavior:

  1. Open calendar with a excluded month and selected is null
  2. Use arrow keys to try and navigate to that excluded month
  3. Excluded month should be pre selected (For invalid time value error select with Enter or Space and try to use the arrow keys again)
  4. Select an available month with the keyboard
  5. Open the calendar again
  6. Try to navigate to the excluded month
  7. Pre selection will stay the same

Expected behavior Consistent behavior when there is a value selected and when there is no value selected. I suggest the date picker should skip over the excluded date when navigated to with the keyboard

Screenshots image

Desktop (please complete the following information):

Storybook v7.5.3

ryantanrk commented 2 months ago

I have made a pull request to address the error being thrown when excluded month is selected with keyboard #4732

ryantanrk commented 2 months ago

POC for skipping excluded dates https://github.com/ryantanrk/react-datepicker/pull/1

ryantanrk commented 1 month ago

Since the pull request has been merged, I will close this issue, thanks