Skip to content

Conversation

nigel5
Copy link
Contributor

@nigel5 nigel5 commented Dec 8, 2018

Users with screen readers have difficulty closing the datepicker popup
obviously because they would have a hard time tapping the backdrop.
Also, on mobile device screen readers they do not have an escape key.

datepickera11yclosedemo

@nigel5 nigel5 requested a review from mmalerba as a code owner December 8, 2018 05:51
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 8, 2018
@nigel5
Copy link
Contributor Author

nigel5 commented Dec 8, 2018

issue #14379

@@ -0,0 +1,9 @@
<div class="mat-calendar-footer cdk-visually-hidden">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jelbourn shouldn't we show the button if it receives focus? Otherwise people that are tabbing through the dialog without screen readers will land on it with no feedback. See how GitHub does it with their "Skip to content" button.

github_-_google_chrome_2018-12-09_09-57-00

@nigel5
Copy link
Contributor Author

nigel5 commented Dec 10, 2018

Hi @crisbeto ,

I appreciate your feedback. I have added the appropriate unit tests and removed the useless cdkAriaLive attribute from the button. Please keep me posted on whether the button should be shown when focused.

Thanks!

@jelbourn
Copy link
Member

@crisbeto you make a good point. We could make the button visible while focused by positioning it at the bottom-right corner as position: absolute on top of the calendar content.

@nigel5
Copy link
Contributor Author

nigel5 commented Dec 14, 2018

@jelbourn @crisbeto I updated the button so it shows when keyboard focused. this is what it looks like right now,

datepickera11ydemo

@jelbourn
Copy link
Member

@mmalerba can you take a look?

@@ -145,6 +145,9 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
/** An input indicating the type of the custom header component for the calendar, if set. */
@Input() calendarHeaderComponent: ComponentType<any>;

/** An input indicating the type of the custom footer component for the calendar, if set. */
@Input() calendarFooterComponent: ComponentType<any>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about this, I don't think we want to let users drop content in here. At least not the way it's currently set up in this PR, the content will just wind up floating below the calendar.

For now how about just putting a button in mat-datepicker-content and we can consider opening it up via an API at some point in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Users with screen readers have difficulty closing the datepicker popup
obviously because they would have a hard time tapping the backdrop.
Also, on mobile device screen readers they do not have an escape key.
@mmalerba mmalerba added aaa and removed aaa labels Apr 25, 2019
@Orodan
Copy link

Orodan commented May 3, 2019

Is there any help needed to finish up this PR ? From what I can see the main content is ok and approved and the last work is about making the changes pass the CI right ?

Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wrote some comments but forgot to send them

</mat-calendar>

<!-- An invisible close button so users with screen readers can easily close the datepicker -->
<div cdkMonitorSubtreeFocus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like overkill, you can just use (focus) and (blur) events on the button

position: absolute;
margin-top: 10px;
&.cdk-keyboard-focused {
background: #2468cf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these colors coming from? Would a mat-raised-button with color="primary" work instead?

&.cdk-keyboard-focused {
background: #2468cf;
color: #ffffff;
z-index: 999;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unnecessarily high, will z-index: 1 work?

super(elementRef);
}

ngAfterViewInit() {
this._calendar.focusActiveCell();
}

formatOrigin(origin: FocusOrigin): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a boolean variable (e.g. isCloseButtonFocused)

return origin ? origin + ' focused' : 'blurred';
}

markForCheck() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be necessary if you switch to just using the (focus) and (blur) events

/** For the focus monitor */
closeButtonElementOrigin: string = this.formatOrigin(null);

get closeButtonLabel(): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getters compile down to a lot of code (relative to just a plain method). Can you change this to a method (e.g. getCloseButtonLabel), or just make _intl public and access it directly in the template

@MohammadRafik
Copy link

MohammadRafik commented Nov 22, 2021

Issue #14379 has been fixed by PR #20666.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants