Skip to content

fix(material/datepicker): a couple of accessibility issues in touch UI mode #21228

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

Merged
merged 1 commit into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/material/datepicker/calendar-body.scss
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ $mat-calendar-range-end-body-cell-size:
}
}

// Allows for the screen reader close button to be seen in touch UI mode.
.mat-datepicker-dialog .mat-dialog-container {
position: relative;
overflow: visible;
}

@include cdk-high-contrast(active, off) {
.mat-datepicker-popup:not(:empty),
.mat-calendar-body-selected {
Expand Down
5 changes: 4 additions & 1 deletion src/material/datepicker/datepicker-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,10 @@ export abstract class MatDatepickerBase<C extends MatDatepickerControl<D>, S,
maxWidth: '80vw',
maxHeight: '',
position: {},
autoFocus: true,

// Disable the dialog's automatic focus capturing, because it'll go to the close button
// automatically. The calendar will move focus on its own once it renders.
autoFocus: false,

// `MatDialog` has focus restoration built in, however we want to disable it since the
// datepicker also has focus restoration for dropdown mode. We want to do this, in order
Expand Down
2 changes: 1 addition & 1 deletion src/material/datepicker/datepicker-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<button
type="button"
mat-raised-button
color="primary"
[color]="color || 'primary'"
class="mat-datepicker-close-button"
[class.cdk-visually-hidden]="!_closeButtonFocused"
(focus)="_closeButtonFocused = true"
Expand Down