-
Notifications
You must be signed in to change notification settings - Fork 397
chore(accessibility): Add aria attributes to aid screen reader flow #117
base: main
Are you sure you want to change the base?
Conversation
613ccb9
to
597ac5f
Compare
@@ -1,5 +1,6 @@ | |||
<div class="docs-component-category-list"> | |||
<md-card | |||
role="link" |
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.
I think a better approach for this one would be to wrap the entire card inside of an anchor element.
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.
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?
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.
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" |
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.
I'm wondering if we should avoid having <nav>
inside of a role="navigation"
and instead wrap the entire sidenav content in one <nav>
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.
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" |
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.
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" |
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.
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 { |
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.
Should be prefixed as .docs-guide-container
@@ -29,7 +29,7 @@ const DOCS = [ | |||
}, | |||
{ | |||
id: 'nav', | |||
name: 'Navigation', | |||
name: 'Navigation Components', |
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.
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?
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.
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" |
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.
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(); |
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.
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
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.
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.
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.
@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?
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.
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.
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.
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.
src/app/shared/navbar/navbar.html
Outdated
@@ -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"> |
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.
I'm not sure role="navigation"
should be necessary for a <nav>
element
src/app/shared/navbar/navbar.html
Outdated
<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> |
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.
role="link"
shouldn't be necessary for an <a>
element
06046b4
to
786c7c1
Compare
786c7c1
to
7b82ca6
Compare
Issue: User action:
Solutions:
Notes:
|
6a72f43
to
7967c1b
Compare
7967c1b
to
27837ab
Compare
27837ab
to
a3b3acf
Compare
This is to address #111 issues