Skip to content

Conversation

amansachdev
Copy link
Contributor

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 #5444 and partially addresses #332

…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
@rtivital rtivital added the ? label Jun 16, 2025
@rtivital rtivital requested a review from Copilot June 16, 2025 10:02
Copy link
Contributor

@Copilot Copilot AI left a 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.
  ],

@rtivital rtivital merged commit af41228 into mantinedev:master Jul 22, 2025
1 check passed
@rtivital
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DatePickerInput keyboard accessibility
2 participants