@@ -23,9 +23,9 @@ angular.module('myApp', ['ngAria'])...
23
23
###Using ngAria
24
24
Most of what ngAria does is only visible "under the hood". To see the module in action, once you've
25
25
added it as a dependency, you can test a few things:
26
- * Using your favorite element inspector, look for ngAria attributes in your own code.
26
+ * Using your favorite element inspector, look for attributes added by ngAria in your own code.
27
27
* Test using your keyboard to ensure `tabindex` is used correctly.
28
- * Fire up a screen reader such as VoiceOver to listen for ARIA support.
28
+ * Fire up a screen reader such as VoiceOver or NVDA to check for ARIA support.
29
29
[Helpful screen reader tips.](http://webaim.org/articles/screenreader_testing/)
30
30
31
31
##Supported directives
@@ -41,8 +41,8 @@ Currently, ngAria interfaces with the following directives:
41
41
42
42
<h2 id="ngmodel">ngModel</h2>
43
43
44
- Most of ngAria's heavy lifting happens in the {@link ngModel ngModel}
45
- directive. For elements using ngModel, special attention is paid by ngAria if that element also
44
+ Much of ngAria's heavy lifting happens in the {@link ngModel ngModel}
45
+ directive. For elements using ngModel, special attention is paid by ngAria if that element also
46
46
has a role or type of `checkbox`, `radio`, `range` or `textbox`.
47
47
48
48
For those elements using ngModel, ngAria will dynamically bind and update the following ARIA
@@ -134,10 +134,8 @@ attributes (if they have not been explicitly specified by the developer):
134
134
135
135
ngAria will also add `tabIndex`, ensuring custom elements with these roles will be reachable from
136
136
the keyboard. It is still up to **you** as a developer to **ensure custom controls will be
137
- operable** from the keybard. Think of `ng-click` on a `<div>` or `<md-checkbox>`: you still need
138
- to bind `ng-keypress` to make it fully operable from the keyboard. As a rule, any time you create
139
- a widget involving user interaction, be sure to test it with your keyboard and at least one mobile
140
- and desktop screen reader (preferably more).
137
+ accessible**. As a rule, any time you create a widget involving user interaction, be sure to test
138
+ it with your keyboard and at least one mobile and desktop screen reader.
141
139
142
140
<h2 id="ngdisabled">ngDisabled</h2>
143
141
@@ -160,7 +158,7 @@ Becomes:
160
158
```
161
159
162
160
>You can check whether a control is legitimately disabled for a screen reader by visiting
163
- [chrome://accessibility](chrome://accessibility).
161
+ [chrome://accessibility](chrome://accessibility) and inspecting [the accessibility tree](http://www.paciellogroup.com/blog/2015/01/the-browser-accessibility-tree/) .
164
162
165
163
<h2 id="ngshow">ngShow</h2>
166
164
@@ -210,16 +208,25 @@ The default CSS for `ngHide`, the inverse method to `ngShow`, makes ngAria redun
210
208
`display: none`. See explanation for {@link guide/accessibility#ngshow ngShow} when overriding the default CSS.
211
209
212
210
<h2><span id="ngclick">ngClick</span> and <span id="ngdblclick">ngDblclick</span></h2>
213
- If `ng-click` or `ng-dblclick` is encountered, ngAria will add `tabindex="0"` if it isn't there
214
- already.
211
+ If `ng-click` or `ng-dblclick` is encountered, ngAria will add `tabindex="0"` to any element not in
212
+ a node blacklist:
215
213
216
- To fix widespread accessibility problems with `ng-click` on div elements, ngAria will dynamically
217
- bind keypress by default as long as the element isn't an anchor, button, input or textarea.
218
- You can turn this functionality on or off with the `bindKeypress` configuration option. ngAria
219
- will also add the `button` role to communicate to users of assistive technologies.
214
+ * Button
215
+ * Anchor
216
+ * Input
217
+ * Textarea
218
+ * Select
219
+ * Details/Summary
220
220
221
- For `ng-dblclick`, you must still manually add `ng-keypress` and role to non-interactive elements such
222
- as `div` or `taco-button` to enable keyboard access.
221
+ To fix widespread accessibility problems with `ng-click` on `div` elements, ngAria will
222
+ dynamically bind a keypress event by default as long as the element isn't in the node blacklist.
223
+ You can turn this functionality on or off with the `bindKeypress` configuration option.
224
+
225
+ ngAria will also add the `button` role to communicate to users of assistive technologies. This can
226
+ be disabled with the `bindRoleForClick` configuration option.
227
+
228
+ For `ng-dblclick`, you must still manually add `ng-keypress` and a role to non-interactive elements
229
+ such as `div` or `taco-button` to enable keyboard access.
223
230
224
231
<h3>Example</h3>
225
232
```html
@@ -260,62 +267,18 @@ The attribute magic of ngAria may not work for every scenario. To disable indivi
260
267
you can use the {@link ngAria.$ariaProvider#config config} method. Just keep in mind this will
261
268
tell ngAria to ignore the attribute globally.
262
269
263
- <example module="ngAria_ngDisabledExample " deps="angular-aria.js">
270
+ <example module="ngAria_ngClickExample " deps="angular-aria.js">
264
271
<file name="index.html">
265
- <style>
266
- [role=checkbox] {
267
- cursor: pointer;
268
- display: inline-block;
269
- }
270
- [role=checkbox] .icon:before {
271
- content: '\2610';
272
- display: inline-block;
273
- font-size: 2em;
274
- line-height: 1;
275
- vertical-align: middle;
276
- speak: none;
277
- }
278
- [role=checkbox].active .icon:before {
279
- content: '\2611';
280
- }
281
- </style>
282
- <form ng-controller="formsController">
283
- <div ng-model="someModel" show-attrs>
284
- Div with ngModel and aria-invalid disabled
285
- </div>
286
- <div role="checkbox" ng-model="checked" ng-class="{active: checked}"
287
- aria-label="Custom Checkbox" ng-click="toggleCheckbox()" some-checkbox show-attrs>
288
- <span class="icon" aria-hidden="true"></span>
289
- Custom Checkbox for comparison
272
+ <div ng-click="someFunction" show-attrs>
273
+ <div> with ng-click and bindRoleForClick, tabindex set to false
290
274
</div>
291
- </form>
292
275
<script>
293
- angular.module('ngAria_ngDisabledExample ', ['ngAria'], function config($ariaProvider) {
276
+ angular.module('ngAria_ngClickExample ', ['ngAria'], function config($ariaProvider) {
294
277
$ariaProvider.config({
295
- ariaInvalid : false,
296
- tabindex: true
278
+ bindRoleForClick : false,
279
+ tabindex: false
297
280
});
298
281
})
299
- .controller('formsController', function($scope){
300
- $scope.checked = false;
301
- $scope.toggleCheckbox = function(){
302
- $scope.checked = !$scope.checked;
303
- }
304
- })
305
- .directive('someCheckbox', function(){
306
- return {
307
- restrict: 'A',
308
- link: function($scope, $el, $attrs) {
309
- $el.on('keypress', function(event){
310
- event.preventDefault();
311
- if(event.keyCode === 32 || event.keyCode === 13){
312
- $scope.toggleCheckbox();
313
- $scope.$apply();
314
- }
315
- });
316
- }
317
- }
318
- })
319
282
.directive('showAttrs', function() {
320
283
return function(scope, el, attrs) {
321
284
var pre = document.createElement('pre');
0 commit comments