Skip to content
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

chore(accessibility): Add aria attributes to aid screen reader flow #117

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

riavalon
Copy link
Contributor

@riavalon riavalon commented Mar 2, 2017

This is to address #111 issues

@@ -1,5 +1,6 @@
<div class="docs-component-category-list">
<md-card
role="link"
Copy link
Member

Choose a reason for hiding this comment

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

I think a better approach for this one would be to wrap the entire card inside of an anchor element.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would have to add an <a role="link"> around the contents of each card, though. Isn't it a bit more concise to just add the role-link to the md-card itself?

Copy link
Member

Choose a reason for hiding this comment

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

In general it's always better to use the appropriate native element instead of a role. An <a> also has the proper associated href and tab index.

@@ -1,9 +1,9 @@
<md-sidenav-container class="docs-component-viewer-sidenav-container">
<md-sidenav #sidenav class="docs-component-viewer-sidenav"
<md-sidenav aria-label="Side navigation" role="navigation" #sidenav class="docs-component-viewer-sidenav"
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we should avoid having <nav> inside of a role="navigation" and instead wrap the entire sidenav content in one <nav>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that this is necessarily a problem. To my knowledge, a <nav> element or an element with role="navigation" just cannot have a <main> or role="main" as a descendant. Adding the role navigation here to allow screen readers to see the whole side nav, and then dig down into the individual sections of the side nav was suggested based off this issue: #111

@@ -1,9 +1,9 @@
<md-sidenav-container class="docs-component-viewer-sidenav-container">
<md-sidenav #sidenav class="docs-component-viewer-sidenav"
<md-sidenav aria-label="Side navigation" role="navigation" #sidenav class="docs-component-viewer-sidenav"
Copy link
Member

Choose a reason for hiding this comment

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

A more informative aria-label might be "Component navigation"

@@ -1,22 +1,24 @@
<!-- TODO(jelbourn): turn this into nav tabs -->
<md-tab-group class="docs-component-viewer-tabbed-content"
<md-tab-group role="tablist" class="docs-component-viewer-tabbed-content"
Copy link
Member

Choose a reason for hiding this comment

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

The roles and other aria attributes are something that really belong as part of the md-tab-group implementation

@@ -1,4 +1,4 @@
:host {
:host, .guides-container {
Copy link
Member

Choose a reason for hiding this comment

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

Should be prefixed as .docs-guide-container

@@ -29,7 +29,7 @@ const DOCS = [
},
{
id: 'nav',
name: 'Navigation',
name: 'Navigation Components',
Copy link
Member

Choose a reason for hiding this comment

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

It's somewhat redundant for this to say "Navigation components" since they're all components. Could it perhaps just be done as an aria label?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I just added "Components" to it since the screen reader otherwise reads it as "Navigation navigation". I'll see if we can change it to an aria label instead. 👍

@@ -3,6 +3,8 @@
<div class="docs-example-viewer-title-spacer">{{exampleData?.title}}</div>

<button md-icon-button type="button" (click)="toggleSourceView()"
role="button"
Copy link
Member

Choose a reason for hiding this comment

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

role="button" should never be necessary on a <button> element

(here and elsewhere)

// Focus host element after view loads
// so screen readers will be alerted
// the page has changed.
this._element.nativeElement.focus();
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a very risky change to make; generally having an element grab focus to itself without user input can cause problems. I'll try to look into alternate approaches

Copy link
Contributor Author

@riavalon riavalon Mar 9, 2017

Choose a reason for hiding this comment

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

We mostly just need to find a way to signify that the page has changed after a user navigates with a screen reader. At the moment, there is no indication that anything has happened. It was recommended that we focus a heading in the main content area of the page, though I definitely agree that it does feel like there should be a better way to signify this.

Choose a reason for hiding this comment

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

@riavalon have you tried setting a document title? I would expect a screen reader to notice and announce a change in the title. Have a look here: https://angular.io/docs/ts/latest/cookbook/set-document-title.html
Can you see if this is a better solution?

Copy link
Contributor Author

@riavalon riavalon Mar 21, 2017

Choose a reason for hiding this comment

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

I actually tried this already, @naomiblack. Even with a title change the screen reader does not announce anything else. Though, updating the document title during navigation seems like a good thing to have anyway. I can add that back in.

Choose a reason for hiding this comment

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

that is definitely weird. I'll see if I can get some help on this one -- yes -- please do add a document title change back in.

@@ -1,12 +1,12 @@
<!-- TODO: figure out if the <nav> should go inside of a <header> element. -->
<nav class="docs-navbar">
<nav aria-label="Main" role="navigation" class="docs-navbar">
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure role="navigation" should be necessary for a <nav> element

<a md-button routerLink="components">Components</a>
<a md-button routerLink="guides">Guides</a>
<a aria-label="Components" role="link" md-button routerLink="components">Components</a>
<a aria-label="Guides" role="link" md-button routerLink="guides">Guides</a>
Copy link
Member

Choose a reason for hiding this comment

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

role="link" shouldn't be necessary for an <a> element

@riavalon riavalon force-pushed the feat-a11y-additions branch 2 times, most recently from 06046b4 to 786c7c1 Compare March 9, 2017 18:28
@DaveBest99
Copy link

Issue:
Page content should not update without being initiated by a user action, or some notification is given to the user (2.4 Alert and Message Dialogs) to inform of the page behaviour.
On the Angular Material demo page (https://material.angular.io/components) the page content is updated when the user presses the Enter key on one of the Navigation Link elements. However, the screen reader does not notify the user that page content has been updated.

User action:

  • Press the Tab key to move focus to a Navigation Link element "Autocomplete".
  • Press Enter key to activate the Link element.
  • Page content updates, but screen reader focus does not move and no screen reader output announces the page change.

Solutions:

  1. Do not move the cursor focus, but announce the page update by adding an aria-alert to the h1 tag "Component - Autocomplete" (2.3 ARIA Alert role).
  2. After the page content updates, upon the Enter key press, move the cursor focus to the h1 tag "Component - Autocomplete" (2.14 ARIA Link - Enter: Executes the link and moves focus to the link target).
  3. Update the page Title by appending the h1 tag "Component - Autocomplete" to the Title (I.E. "Component - Autocomplete - Angular Material").

Notes:

  • WCAG2.4.2 Page Titled: Web pages have titles that describe topic or purpose. (Level A).
    The intent of this Success Criterion is to help users find content and orient themselves within it by ensuring that each Web page has a descriptive title. Titles identify the current location without requiring users to read or interpret page content.
    http://www.w3.org/TR/UNDERSTANDING-WCAG20/complete.html

  • ARIA2.5 Breadcrumb: A breadcrumb trail consists of a list of links to the parent pages of the current page in hierarchical order. It helps users find their place within a website or web application. Breadcrumbs are often placed horizontally before a page's main content.
    http://w3c.github.io/aria-practices/

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

Successfully merging this pull request may close these issues.

5 participants