feat(aio): sidenav headers should be focusable buttons

Sidenav headers had been anchors w/o hrefs. These can’t take focus which makes you can’t navigate through them with keyboard. For a11y purposes, this PR turns them into buttons.
This commit is contained in:
Ward Bell 2017-05-15 14:52:39 -07:00 committed by Pete Bacon Darwin
parent 7ae0440cca
commit a68ad6d58d
5 changed files with 30 additions and 10 deletions

View File

@ -5,8 +5,8 @@ describe('site App', function() {
let page: SitePage; let page: SitePage;
beforeEach(() => { beforeEach(() => {
SitePage.setWindowWidth(1050); // Make the window wide enough to show the SideNav side-by-side.
page = new SitePage(); page = new SitePage();
page.setWindowWidth(1050); // Make the window wide enough to show the SideNav side-by-side.
page.navigateTo(); page.navigateTo();
}); });

View File

@ -3,6 +3,7 @@ import { browser, element, by, promise, ElementFinder } from 'protractor';
const githubRegex = /https:\/\/github.com\/angular\/angular\//; const githubRegex = /https:\/\/github.com\/angular\/angular\//;
export class SitePage { export class SitePage {
links = element.all(by.css('md-toolbar a')); links = element.all(by.css('md-toolbar a'));
docsMenuLink = element(by.cssContainingText('aio-top-menu a', 'Docs')); docsMenuLink = element(by.cssContainingText('aio-top-menu a', 'Docs'));
docViewer = element(by.css('aio-doc-viewer')); docViewer = element(by.css('aio-doc-viewer'));
@ -12,8 +13,14 @@ export class SitePage {
.filter((a: ElementFinder) => a.getAttribute('href').then(href => githubRegex.test(href))) .filter((a: ElementFinder) => a.getAttribute('href').then(href => githubRegex.test(href)))
.first(); .first();
gaReady: promise.Promise<any>; gaReady: promise.Promise<any>;
static setWindowWidth(newWidth: number) {
const win = browser.driver.manage().window();
return win.getSize().then(oldSize => win.setSize(newWidth, oldSize.height));
}
getNavItem(pattern: RegExp) { getNavItem(pattern: RegExp) {
return element.all(by.css('aio-nav-item a')) return element.all(by.css('aio-nav-item .vertical-menu-item'))
.filter(element => element.getText().then(text => pattern.test(text))) .filter(element => element.getText().then(text => pattern.test(text)))
.first(); .first();
} }
@ -35,11 +42,6 @@ export class SitePage {
return browser.executeScript('return arguments[0].innerHTML;', element); return browser.executeScript('return arguments[0].innerHTML;', element);
} }
setWindowWidth(newWidth: number) {
const win = browser.driver.manage().window();
return win.getSize().then(oldSize => win.setSize(newWidth, oldSize.height));
}
/** /**
* Replace the ambient Google Analytics tracker with homebrew spy * Replace the ambient Google Analytics tracker with homebrew spy
* don't send commands to GA during e2e testing! * don't send commands to GA during e2e testing!

View File

@ -12,11 +12,11 @@
<md-icon class="rotating-icon" svgIcon="keyboard_arrow_right"></md-icon> <md-icon class="rotating-icon" svgIcon="keyboard_arrow_right"></md-icon>
</a> </a>
<a *ngIf="node.url == null" [ngClass]="classes" title="{{node.tooltip}}" <button *ngIf="node.url == null" type="button" [ngClass]="classes" title="{{node.tooltip}}"
(click)="headerClicked()" class="vertical-menu-item heading"> (click)="headerClicked()" class="vertical-menu-item heading">
{{node.title}} {{node.title}}
<md-icon class="rotating-icon" svgIcon="keyboard_arrow_right"></md-icon> <md-icon class="rotating-icon" svgIcon="keyboard_arrow_right"></md-icon>
</a> </button>
<div class="heading-children" [ngClass]="classes"> <div class="heading-children" [ngClass]="classes">
<aio-nav-item *ngFor="let node of node.children" [level]="level + 1" <aio-nav-item *ngFor="let node of node.children" [level]="level + 1"

View File

@ -66,7 +66,10 @@ md-sidenav-container div.mat-sidenav-content {
&:hover { &:hover {
background-color: $lightgray; background-color: $lightgray;
}
&:focus {
color: $darkgray;
} }
//icons _within_ nav //icons _within_ nav
@ -80,10 +83,24 @@ md-sidenav-container div.mat-sidenav-content {
.vertical-menu-item.selected { .vertical-menu-item.selected {
color: $blue; color: $blue;
&:focus {
color: $blue-900;
}
}
button.vertical-menu-item {
border: none;
background-color: transparent;
padding: 8px 0 8px 20px;
&:focus {
color: $black;
}
} }
.heading { .heading {
color: #444; color: $blue-grey-700;
cursor: pointer; cursor: pointer;
position: relative; position: relative;
text-transform: uppercase; text-transform: uppercase;

View File

@ -34,6 +34,7 @@ $blue-400: #42A5F5;
$blue-500: #2196F3; $blue-500: #2196F3;
$blue-600: #1E88E5; $blue-600: #1E88E5;
$blue-800: #1565C0; $blue-800: #1565C0;
$blue-900: #0D47A1;
$blue-grey-50: #ECEFF1; $blue-grey-50: #ECEFF1;
$blue-grey-100: #CFD8DC; $blue-grey-100: #CFD8DC;
$blue-grey-200: #B0BEC5; $blue-grey-200: #B0BEC5;