Keyboard broken when minDate setted but maxDate null (opposite not tested)
It took me some time to figure that out but when you set the minDate to something but the maxDate to null you get an "Cannot read property 'clone' of null" error, which is I guess the coning of the maxDate property. I fixed that by using a maxDate far in the future but I guess it should be addressed.
Actually, setting minDate or maxDate to null breaks keyboard navigation.
The documentation marks these props as object, but I guess null should be ok too!
So, the only solution is to not set these props at all, which is really unpractical.
EDIT What works is passing an undefined variable instead of null (which is not pretty...).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
2 years and the problem still persists
Just run into this in our project - minimal test case:
import { useState } from "react";
import Datepicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
export default function App() {
const [date, setDate] = useState(new Date());
return <Datepicker selected={date} onChange={setDate} maxDate={null} />;
// return <Datepicker selected={date} onChange={setDate} />;
}
First return - keyboard navigation is broken. Second one - keyboard works correctly.
The reason for this is, as far as I could see, the following:
- Keyboard events, including navigation, are handled in
onDayKeyDown. This includes call tothis.setPreSelection(newSelection)on line 764. - In
setPreSelection, ifminDate !== undefinedormaxDate !== undefined, they are passed (directly or indirectly) tostartOfDay. Note that this doesn't excludenulls. -
startOfDay, when passednull, returnsInvalid Date. - Then, any comparison functions with
Invalid Dateas input, unconditionally returnfalse. - Therefore, the date is considered to be out-of-bounds, and the preselection doesn't happen.
I hope that this is enough info to make a correct fix, either in code or in documentation. Since this issue is closed, ping @martijnrusschen, so that it isn't lost for now.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Just to understand - is the "won't fix" the conscious decision, or did this issue simply get lost?
Still the problem exists in 2023.
Fixed by #4848, it seems?
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This issue was closed because it has been stalled for 10 days with no activity.