This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
docs(step_15): create new step about accessibility #14779
Open
felixzapata
wants to merge
6
commits into
angular:master
Choose a base branch
from
felixzapata:step15-a11y
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6e9015f
docs(step_15): create new step about accessibility
felixzapata 7103297
docs(step_15.ngdoc): update the step 15
felixzapata 62c5f59
docs(step_15): update document following marcysutton comments
felixzapata 1300f80
docs(step_15): add more information about the protractor plugin
felixzapata c8c2dfd
docs(step_15): update document
felixzapata 6a7b77f
docs(step_15): update the doc
felixzapata File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
@ngdoc tutorial | ||
@name 15 - Accessibility | ||
@step 15 | ||
@description | ||
|
||
<ul doc-tutorial-nav="15"></ul> | ||
|
||
In this step, we will learn how to fix the accessibility issues in the application. | ||
|
||
* We will fix some issues in the templates. | ||
* We will use the [protractor-accessibility-plugin](protractor-a11y-plugin) to review the accessibility of our application when we run our e2e tests. | ||
|
||
<div doc-tutorial-reset="15"></div> | ||
|
||
## Why accessibility matters | ||
|
||
A website or application accessible allows the users with different preferences and abilitities, | ||
to consume the content in a way that suits their needs. | ||
|
||
* [Creating an accessible web - Access iQ](https://www.youtube.com/watch?v=47n0wEcm6JU) | ||
* [Web Accessibility](https://www.youtube.com/watch?v=bEM9Fn9aOG8) | ||
* [Google Accessibility course](https://webaccessibility.withgoogle.com/course) | ||
* [Accessibility in AngularJS and Beyond](http://marcysutton.com/slides/fluent2015/) | ||
* [Introduction to Web Accessibility](https://www.w3.org/WAI/intro/accessibility.php) | ||
* [Notes On Client-Rendered Accessibility](https://www.smashingmagazine.com/2015/05/client-rendered-accessibility/) | ||
* [Apps For All: Coding Accessible Web Applications](https://shop.smashingmagazine.com/products/apps-for-all) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's one more article that was written in response to Angular a11y: https://www.smashingmagazine.com/2015/05/client-rendered-accessibility/ |
||
## About WAI-ARIA | ||
|
||
WAI-ARIA (_the Accessible Rich Internet Applications Suite_) is a standard set of attributes used | ||
to fill accessibility support gaps in custom HTML elements and SVG. | ||
|
||
AngularJS has a module called {@link ngAria ngAria} to help developers to add some WAI-ARIA attributes easily in your application. | ||
|
||
## Main accessibility issues in the application | ||
|
||
If you make a review of the accessibility of the application you will find some issues: | ||
|
||
* Lack of information about the current results when the user interacts with the filters. | ||
* Lack of labels elements in the search and order filters in the Phone list. | ||
* Lack of headers elements to help the user to navigate throw the content of the page. | ||
* In the Phone detail, the user can't access via keyboard over the thumbnails images. | ||
|
||
In the next sections we are going to show you, how to fix some of these issues | ||
to make the application accessible. | ||
|
||
To help us, we can use the [protractor-a11y-plugin] plugin to check | ||
potential issues in the application. | ||
|
||
This plugin [runs an audit](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules) locally by injecting the Dev Tools script into WebDriver pages, and it can diagnose issues including missing labels, incorrect ARIA attributes and color contrast. This is a great starting point if you can't send source code over the wire through an API. | ||
|
||
## How to inform the user that _something_ is happening | ||
|
||
Today, is very common to find applications or webpages where the user make some interaction | ||
with an element and obtains and inmediate reply to the action. | ||
|
||
The problem is that in most of the cases this action is only reported in a way that you need to see it in your screen but if a user is navigating with a screenreader like [JAWS](http://www.freedomscientific.com/Products/Blindness/JAWS), [NVDA](http://www.nvaccess.org/) or [ChromeVox](http://www.chromevox.com/), this information never won't be accessible. | ||
|
||
When the user is searching or filtering mobiles in the application, the list updates automatically. | ||
It is mandatory that user knows, in some way, the result after the search or order action. | ||
|
||
To fix this, we add two directives to inform the user how many items are now in the list | ||
after search or order them. This directive will fill an element in our page | ||
to tell the user how many elements are after the action. | ||
|
||
<br /> | ||
**`app/phone-list/phone-list-template.html`:** | ||
|
||
```html | ||
<div> | ||
<label for="search">Search:</label> | ||
<input id="search" ng-model="$ctrl.query" ng-model-options="{ debounce: 300 }"> | ||
</div> | ||
|
||
<div class="aria-status" aria-live="assertive" aria-atomic="true"></div> | ||
|
||
... | ||
|
||
<div class="aria-status-sort" aria-live="assertive" aria-atomic="true"></div> | ||
|
||
``` | ||
|
||
The new element is a _live region_. It means that every time this region is updated, | ||
it will inform the user about its content. | ||
|
||
In order to update the information correctly, it is neccesary to add a [_`debounce`_](https://docs.angularjs.org/api/ng/directive/ngModelOptions) option | ||
to the model. | ||
|
||
Please note that now the inputs are associated with theirs labels using `label` elements. | ||
|
||
The directives are based on an idea of [Marcy Sutton](http://marcysutton.com/slides/fluent2015/) about how to add accessibility in the AngularJS applications. | ||
|
||
[You can learn more about directives, following the AngularJS guide](https://docs.angularjs.org/guide/directive). | ||
|
||
|
||
## Using the keyboard | ||
|
||
The current detail of a phone prevents a user to use a keyboard to navigate for over each thumbnail | ||
image. It is very important due to accessibility that all the actions and information | ||
are available via keyboard too. For example, lightboxes, carousels, slides, etc. | ||
|
||
_Tip_: Try to navigate over the application using only the _TAB_ key. | ||
You will discover that some actions can't be accessed nor the focus on some elements. | ||
|
||
<br /> | ||
**`app/phone-detail/phone-detail.template.html`:** | ||
|
||
```html | ||
... | ||
<ul class="phone-thumbs"> | ||
<li ng-repeat="img in $ctrl.phone.images"> | ||
<button type="button" aria-label="view enlarge version of the image" ng-click="$ctrl.setImage(img)"><img ng-src="{{img}}" alt="" /></button> | ||
</li> | ||
</ul> | ||
... | ||
``` | ||
|
||
To fix this issue, we add a `button` element, wrapping the image to allow | ||
the user to access the content via keyboard. | ||
|
||
Why we are using a `button` element instead of an `a` element? | ||
Because it does not navigate to a new page or resource. | ||
|
||
## How to run the e2e tests using the Protractor accessibility plugin | ||
|
||
Once we install the plugin, every time we run the e2e tests, | ||
Protractor will review the accessibility of your application. | ||
|
||
### Dependencies | ||
|
||
To install the [protractor-a11y-plugin], we can add the plugin into the `devDependencies` section | ||
in the `package.json` file, | ||
|
||
**`package.json`:** | ||
|
||
``` | ||
{ | ||
"devDependencies": { | ||
"bower": "^1.7.7", | ||
"http-server": "^0.9.0", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^0.13.22", | ||
"karma-chrome-launcher": "^0.2.3", | ||
"karma-firefox-launcher": "^0.1.7", | ||
"karma-jasmine": "^0.3.8", | ||
"protractor": "^3.2.2", | ||
"protractor-accessibility-plugin": "^0.1.1", | ||
"shelljs": "^0.6.0" | ||
} | ||
} | ||
``` | ||
|
||
Now, we must tell bower to download and install these dependencies. | ||
|
||
``` | ||
npm install | ||
``` | ||
|
||
<div class="alert alert-info"> | ||
**Note:** If you have bower installed globally, you can run `bower install`, but for this project | ||
we have preconfigured `npm install` to run bower for us. | ||
</div> | ||
|
||
<div class="alert alert-warning"> | ||
**Warning:** If a new version of Angular has been released since you last ran `npm install`, then | ||
you may have a problem with the `bower install` due to a conflict between the versions of | ||
angular.js that need to be installed. If you run into this issue, simply delete your | ||
`app/bower_components` directory and then run `npm install`. | ||
</div> | ||
|
||
Once the plugin is installed, we have to modify the `protractor.conf.js` file to inform Protractor | ||
to use this plugin too. | ||
|
||
**`protractor.conf.js`:** | ||
|
||
``` | ||
plugins: [{ | ||
chromeA11YDevTools: { | ||
treatWarningsAsFailures: true | ||
}, | ||
package: 'protractor-accessibility-plugin' | ||
}] | ||
``` | ||
|
||
# Summary | ||
|
||
Our application is now accessible, thanks to these small changes. | ||
|
||
There you have it! We have created a web application in a relatively short amount of time. In the | ||
{@link the_end closing notes} we will cover where to go from here. | ||
|
||
|
||
<ul doc-tutorial-nav="15"></ul> | ||
|
||
|
||
[bower]: http://bower.io/ | ||
[protractor-a11y-plugin]: https://github.com/angular/protractor-accessibility-plugin |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you add a paragraph on what is "accessibility" and "aria" and how it affects people. Just a brief summary and then list the links for more info.
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.
ok, I'm on it.
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've added some definitions.