-
Problem statement:Issue: as soon as there is DayButton component provision keyboard navigation through picker date stops working as expected. It might be just my misunderstanding but I assume it's either not enough just to provide the button component with props drilling or it might be an issue. LinksEnvironment:
ThoughtsI've conducted shallow investigation and the focusedDay seems to be right determined through the context My educated guess would be that there is no access to the focused context to me as an end-consumer of the library. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
@dzianis-l const ref = React.useRef<HTMLButtonElement>(null);
React.useEffect(() => {
if (modifiers.focused) ref.current?.focus();
}, [modifiers.focused]);You can copy and paste this logic into your custom components. import { DayButton } from "react-day-picker";
function CustomDayButton(props) {
// Simple props drilling
return <DayButton {...props} />;
} |
Beta Was this translation helpful? Give feedback.
@dzianis-l
it's because the core
DayButtonhas internal logic required to work as expected:You can copy and paste this logic into your custom components.
But we recommend reusing the core components in the custom components to always have the core logic up to date.
E.g.: