Skip to content

Commit 5a9c51f

Browse files
authored
fix(Calendar): prevent default behaviour on navigation (#26)
1 parent 88305d9 commit 5a9c51f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/components/Calendar/hooks/useCalendarGridProps.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,37 @@ export function useCalendarGridProps(state: CalendarState | RangeCalendarState)
2222
...focusWithinProps,
2323
onKeyDown: (e) => {
2424
if (e.key === 'ArrowRight') {
25+
e.preventDefault();
2526
state.focusNextCell();
2627
} else if (e.key === 'ArrowLeft') {
28+
e.preventDefault();
2729
state.focusPreviousCell();
2830
} else if (e.key === 'ArrowDown') {
31+
e.preventDefault();
2932
state.focusNextRow();
3033
} else if (e.key === 'ArrowUp') {
34+
e.preventDefault();
3135
state.focusPreviousRow();
3236
} else if (e.key === 'PageDown') {
37+
e.preventDefault();
3338
state.focusNextPage(e.shiftKey);
3439
} else if (e.key === 'PageUp') {
40+
e.preventDefault();
3541
state.focusPreviousPage(e.shiftKey);
3642
} else if (e.key === 'End') {
43+
e.preventDefault();
3744
state.focusSectionEnd();
3845
} else if (e.key === 'Home') {
46+
e.preventDefault();
3947
state.focusSectionStart();
4048
} else if (e.code === 'Minus') {
49+
e.preventDefault();
4150
state.zoomOut();
4251
} else if (e.code === 'Equal') {
52+
e.preventDefault();
4353
state.zoomIn();
4454
} else if (e.key === 'Enter' || e.key === ' ') {
55+
e.preventDefault();
4556
state.selectDate(state.focusedDate);
4657
}
4758
},

0 commit comments

Comments
 (0)