Hacker0x01 / react-datepicker

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

Allow for the keyboard preselection to skip excluded dates/weeks/months #4817

Closed ryantanrk closed 4 months ago

ryantanrk commented 4 months ago

name: Allow for skipping of excluded dates/weeks/months about: Create a pull request to improve this repository title: Allow for skipping of excluded dates/weeks/months labels: "" assignees: ""

Description

Linked issue: #4731

Problem Currently, the date picker only stops when the user is about to navigate to an excluded month, which, if let's say there are multiple disabled dates side by side spanning the whole row, the user is unable to navigate to the months after it. This only happens on the month picker.

image

Changes I have made recursive functions in the keydown functionality of the month and day calendar to get a new day/month if the date is disabled/excluded. Even though this is only a month picker thing, I have changed the behavior of the day calendar as well to make it consistent.

Screenshots

Day

https://github.com/Hacker0x01/react-datepicker/assets/49902829/5637ad57-2773-4d69-ba58-a9714167bfed

Week

https://github.com/Hacker0x01/react-datepicker/assets/49902829/ccae4796-7db5-4292-b552-52cc5c74cb72

Month

https://github.com/Hacker0x01/react-datepicker/assets/49902829/54e07d27-1298-4562-a337-f03ab33c6675

To reviewers

If this behavior should be made optional, please let me know

Contribution checklist

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 97.69585% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 96.67%. Comparing base (d594e74) to head (04f208c).

Files Patch % Lines
src/index.tsx 96.29% 4 Missing :warning:
src/week_number.tsx 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #4817 +/- ## ========================================== + Coverage 96.04% 96.67% +0.63% ========================================== Files 28 28 Lines 2880 2978 +98 Branches 1244 1292 +48 ========================================== + Hits 2766 2879 +113 + Misses 114 99 -15 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

martijnrusschen commented 4 months ago

@ryantanrk thanks for the extensive pull request. Since there has been some discussions with the pull request team, I wanted to check if there's any outstanding items to address.

ryantanrk commented 4 months ago

hi @martijnrusschen , i have yet to rewrite the logic according to Luciano's comments, as well as adding more test coverage. i'll update when it's done :)

ryantanrk commented 4 months ago

PR should be good for another review. @martijnrusschen

Would like some opinions on how the edge case where all dates are disabled should be handled