rehookify / datepicker

The ultimate tiny tool for creating date and range pickers in your React applications.
https://rehookify.com/datepicker
MIT License
301 stars 22 forks source link

fix: correctly disabled/enabled addOffset propsGetter with maxDate using the offsetValue #51

Closed susosamuel closed 7 months ago

susosamuel commented 7 months ago

Hello, This is my attempt to fix the behaviour described in https://github.com/rehookify/datepicker/pull/46

I tried the approach that you, @Feshchenko, mentioned in your comments and used the offsetDate in order to achieve the desired behavior without needing to update the disabling logic.

This is an example of what the code does behind the scenes (the same happens in the videos attached below):

Situation 1 - Edge case maxDate:

Situation 2 - Edge case minDate:

I'm also attaching the before and after showcases

Before: https://github.com/rehookify/datepicker/assets/17575434/2b4209a9-072c-4679-a7f5-99692b6643ea

After: https://github.com/rehookify/datepicker/assets/17575434/f8a20c7f-8153-40e9-9b94-0e70fc558820

Props setup from the video: mode: 'single' maxDate: 13.2.2024 minDate: 22.11.2024 selectedDates: [20.1.2024]

fyi @marianadrozdova @ebartunek