-
-
Notifications
You must be signed in to change notification settings - Fork 761
Open
Description
I need a dynamic constraint based on the from date in the range picker. With mouse navigation everything works fine, but when I try to choose a date using the keyboard, the calendar loses focus because the previously focused date is disabled.
Use case:
- User can select any
fromdate todate should be more thenfromdate
To reproduce
- Use the keyboard to navigate to a calendar date.
- Press Enter to select the focused date.
- Try to select
todate by arrow keys
import { useState } from "react";
import { DayPicker, DateRange } from "react-day-picker";
import "react-day-picker/style.css";
export default function Calendar() {
const [selected, setSelected] = useState<DateRange>();
return (
<DayPicker
animate
mode="range"
selected={selected}
min={1}
disabled={[{ before: selected?.from }, selected?.from]}
onSelect={(value, date) => {
setSelected((prevValue) => {
if (prevValue?.from && prevValue?.to) {
return {
from: date,
to: undefined,
};
}
return value;
});
}}
/>
);
}CodeSandbox: https://codesandbox.io/p/sandbox/lv4wfv
Actual Behavior
Arrow keys don’t work to continue selecting the second date.
Expected Behavior
Arrow keys work to continue selecting the to date. The focus should move to the closest available day.
Screenshots
Screen.Recording.2025-11-01.at.13.28.15.mov
Metadata
Metadata
Assignees
Labels
No labels