Skip to content

Commit

Permalink
fix(Calendar): prevent default behaviour on navigation (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS authored Nov 23, 2023
1 parent 88305d9 commit 5a9c51f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/Calendar/hooks/useCalendarGridProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
Expand Down

0 comments on commit 5a9c51f

Please sign in to comment.