-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement dom-based keyboard navigation for year selection * Make calendar keyboard navigation also focus-based * Fix animation freesing because of .focus() in Calendar * Add proper aria-label's for calendar * Properly handle focus when switching months * Announce month and year switching * Make props for customizing aria-label texts * Fix type for useKeyDown handler * Add aria-label for mobile keyboard input button * Fix Prop inference after changing interfaces * Implement force quitting picker onKeyDown * Aria-labels and live regions for date & time picker * Fix day and clock numbers not autofocusing on appear * Fix missing container if `reduceAnimations` * Better default focus management * Add more keyboard shorcats * Add accessibility guide * Fix styles of markdown table * Fix grammar in accessibility guideline * Fix crashing on openning invalid date * Make focus visible when root element of wrapper is focused * Fix not closing mobile dialog with esc * Better match material design accessibility spec * Fix ts error and linters * Add keyboard navigation cypress tests * Skip flaky test
- Loading branch information
1 parent
ac082ff
commit fd86dc2
Showing
49 changed files
with
1,339 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { useState } from 'react'; | ||
import { DatePicker } from '@material-ui/pickers'; | ||
|
||
function BasicDatePicker() { | ||
const [selectedDate, handleDateChange] = useState(new Date()); | ||
|
||
return ( | ||
<DatePicker | ||
disableMaskedInput | ||
placeholder="mm/dd/yyyy" | ||
label="Accessible" | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
); | ||
} | ||
|
||
export default BasicDatePicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import Ad from '_shared/Ad'; | ||
import Example from '_shared/Example'; | ||
import PageMeta from '_shared/PageMeta'; | ||
import * as Accessibility from './Accessibility.example'; | ||
|
||
<PageMeta title="Accessiblity" description="Accessibility guideline for @material-ui/pickers" /> | ||
|
||
## Accessibility | ||
|
||
<Ad /> | ||
|
||
Pickers accessibility is highly impoertant, because this control is becoming completely unusable if there is | ||
no appropriate focus managment. | ||
|
||
The dialog contains a calendar that uses the [grid](https://www.w3.org/TR/wai-aria-practices/#grid) pattern to present buttons that enable the user to choose a day from the calendar. | ||
Choosing a date from the calendar closes the dialog and populates the date input field. When the dialog is opened, | ||
if the input field is empty, or does not contain a valid date, then the current date is focused in the calendar. | ||
Otherwise, the focus is placed on the day in the calendar that matches the value of the date input field. | ||
It is possible to navigate throught the calendar, year selection and clock with only keyboard. | ||
|
||
But still there are some limitations: | ||
|
||
- You need to provide accessible placeholder (`mm/dd/yyyy`) according to used format and locale | ||
- Masked input is not really well announcing via screen readers, so you may consider disable it | ||
|
||
### Example | ||
|
||
Here is working accessible example, compare it to the [wia-aria datepicker dialog example](https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/datepicker-dialog.html) | ||
|
||
<Example source={Accessibility} /> | ||
|
||
### Keyboard shortcats | ||
|
||
Here is the list of avaialble keyboard shortcats allows to control the date and time pickers with only keyboard. | ||
|
||
#### DatePicker | ||
|
||
| Shortcat | Action | | ||
| ------------ | ------------------------------------------------------------------------------------- | | ||
| ArrowUp | Moves focus to the same day of the previous week. | | ||
| ArrowDown | Moves focus to the same day of the next week. | | ||
| ArrowRight | Moves focus to the next day. | | ||
| ArrowLeft | Moves focus to the previous day. | | ||
| Home | Moves focus to the first day (e.g Monday) of the current week. | | ||
| End | Moves focus to the last day (e.g. Sunday) of the current week. | | ||
| Esc | Close dialog or popover | | ||
| Space, Enter | Choose currently focused year or date. Closing picker if current view is the last one | | ||
|
||
#### TimePicker | ||
|
||
| Shortcat | Action | | ||
| ------------ | --------------------------------------------------------------------------------------- | | ||
| ArrowUp | Incrment (hours/minutes/seconds) according to the used step | | ||
| ArrowDown | Decrmeent (hours/minutes/seconds) according to the used step | | ||
| Home | Select maximal value of current clock type (hours/minutes/seconds) | | ||
| End | Select minimal value of current clock type (hours/minutes/seconds) | | ||
| Esc | Close dialog or popover | | ||
| Space, Enter | Accept currently selected selected value, move to the next view or close popover/dialog | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
fd86dc2
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.
Successfully deployed to following URLs: