-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(DatePicker): Add keyboard shortcuts for year navigation accessib… #7959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(DatePicker): Add keyboard shortcuts for year navigation accessib… #7959
Conversation
…ility This PR improves DatePicker accessibility by adding keyboard shortcuts for year navigation, addressing the need for better keyboard support when selecting dates far in the past (like birth dates). New keyboard shortcuts: - Ctrl/Cmd + Arrow Up/Down: Navigate by year - Ctrl/Cmd + Shift + Arrow Up/Down: Navigate by decade - Y key: Open year selection view Changes: - Added enableKeyboardNavigation prop to Calendar component (enabled by default) - Implemented keyboard event handlers for year/decade navigation - Added comprehensive test coverage for keyboard navigation - Created demo showcasing the new feature - Added documentation for keyboard shortcuts Fixes mantinedev#5444 and partially addresses mantinedev#332
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the DatePicker’s accessibility by adding keyboard shortcuts for year and decade navigation. The changes include updated prop definitions for keyboard navigation support, new event handlers in the Calendar component, demo updates, and accompanying documentation.
- Added enableKeyboardNavigation prop to propagate keyboard navigation functionality from DatePicker to Calendar.
- Implemented keyboard event handling for year and decade navigation including a key-based shortcut for opening the year view.
- Updated demo and documentation files to showcase and explain the new keyboard shortcuts.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/@mantine/dates/src/components/DatePicker/DatePicker.tsx | Updated prop types to include keyboard navigation options from CalendarProps. |
packages/@mantine/dates/src/components/Calendar/Calendar.tsx | Added keyboard event handling via useEffect and updated default props. |
packages/@docs/demos/src/demos/dates/DatePicker/index.ts | Exported new keyboardNavigation demo. |
packages/@docs/demos/src/demos/dates/DatePicker/DatePicker.demo.keyboardNavigation.tsx | Created demo showcasing keyboard navigation usage. |
docs/keyboard-navigation.md | Added documentation for the new keyboard shortcut features. |
Comments suppressed due to low confidence (1)
packages/@mantine/dates/src/components/Calendar/Calendar.tsx:397
- The dependency array for the keyboard navigation effect includes several callback functions (e.g., handleNextYear, handlePreviousYear, etc.). Consider memoizing these functions with useCallback to avoid unnecessary re-renders and repeated event listener registrations.
],
packages/@docs/demos/src/demos/dates/DatePicker/DatePicker.demo.keyboardNavigation.tsx
Outdated
Show resolved
Hide resolved
Thanks! |
This PR improves DatePicker accessibility by adding keyboard shortcuts for year navigation, addressing the need for better keyboard support when
selecting dates far in the past (like birth dates).
New keyboard shortcuts:
Changes:
Fixes #5444 and partially addresses #332