From 5a9c51fe10de8b8652196bcb2bcc22015cbf9d4b Mon Sep 17 00:00:00 2001 From: Valerii Sidorenko Date: Thu, 23 Nov 2023 14:56:23 +0100 Subject: [PATCH] fix(Calendar): prevent default behaviour on navigation (#26) --- src/components/Calendar/hooks/useCalendarGridProps.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/Calendar/hooks/useCalendarGridProps.ts b/src/components/Calendar/hooks/useCalendarGridProps.ts index 653dc92..463d2a0 100644 --- a/src/components/Calendar/hooks/useCalendarGridProps.ts +++ b/src/components/Calendar/hooks/useCalendarGridProps.ts @@ -22,26 +22,37 @@ export function useCalendarGridProps(state: CalendarState | RangeCalendarState) ...focusWithinProps, onKeyDown: (e) => { if (e.key === 'ArrowRight') { + e.preventDefault(); state.focusNextCell(); } else if (e.key === 'ArrowLeft') { + e.preventDefault(); state.focusPreviousCell(); } else if (e.key === 'ArrowDown') { + e.preventDefault(); state.focusNextRow(); } else if (e.key === 'ArrowUp') { + e.preventDefault(); state.focusPreviousRow(); } else if (e.key === 'PageDown') { + e.preventDefault(); state.focusNextPage(e.shiftKey); } else if (e.key === 'PageUp') { + e.preventDefault(); state.focusPreviousPage(e.shiftKey); } else if (e.key === 'End') { + e.preventDefault(); state.focusSectionEnd(); } else if (e.key === 'Home') { + e.preventDefault(); state.focusSectionStart(); } else if (e.code === 'Minus') { + e.preventDefault(); state.zoomOut(); } else if (e.code === 'Equal') { + e.preventDefault(); state.zoomIn(); } else if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); state.selectDate(state.focusedDate); } },