-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(ngAria): New module to make a11y easier #8342
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
Interesting. The current implementation is not ideal because it requires on reading the DOM state during digest (which is super slow), so we can't merge this as is. In many cases we could instead use $attrs.$observe to intercept attribute changes instead of watching them (that won't work for class attribute though because we use classList if available). @naomiblack can you or someone else review this for correctness from the a11y perspective? |
(from #5486 (comment) )
nvm just saw this was triaged |
@IgorMinar Code is now changed to use $attrs.$observe where possible |
* | ||
* Currently, the following aria tags are implemented: | ||
* | ||
* + aria-hidded |
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.
s/hidded/hidden/
* | ||
* + aria-hidden | ||
* + aria-checked | ||
* + aria-diabled |
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.
aria-disabled
?
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 an useful attribute where ng-disabled
is used to disabled certain fields based on the state of the form like so:
<form name="myForm">
...
<input type="submit" ng-disabled="!myForm.$valid">
</form>
More info on aria-disabled
: http://www.w3.org/TR/wai-aria/states_and_properties#aria-disabled
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.
Sorry, I was just pointing out a misspelling in the doc. Thanks for the great info though!
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, sorry didn't realize that. Updated now, thanks!
@marcysutton do you think this is good to go? |
* Requires the {@link ngAria `ngAria`} module to be installed. | ||
*/ | ||
function $AriaProvider(){ | ||
var config = { |
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.
Are there other ARIA states and properties that would make sense to add here? What about aria-expanded
, aria-label
, aria-controls
and others? Should those be added on an as-needed-and-tested basis?
@btford I have a few questions about the directive to try and understand the scope and intention. It definitely makes sense to add support for tried and tested patterns, such as |
|
||
describe('aria-hidden', function(){ | ||
beforeEach(function(){ | ||
setupModule(); |
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.
why not just beforeEach(module('ngAria'))
?
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.
fixed!
@arbus, tabs are definitely tricky to get right. I'd agree that omitting ARIA for tabs is a good idea at this point. I also don't think live regions make sense to add across the board (but I could be proven otherwise). Whether polling updates would be useful to AT users really depends on the context. I'd also want to make sure there aren't any performance issues before introducing them to Angular core. I am experimenting with demos to make sure the use cases check out. One edit we should consider making now, however, is to check whether an ARIA attribute already exists before injecting it. We're doing that on AngularJS Material to make sure we don't stomp on top of the work by folks who know what they're doing. Any thoughts on that? |
+1; we should probably add a benchmark: https://github.com/angular/angular.js/tree/master/benchmarks
+1; I think this makes sense. |
}); | ||
}); | ||
|
||
describe('aria-requried', function(){ |
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.
typo
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.
fixed, thanks for pointing it out!
Ok, cool. Some more comments in the module would help maintainability, as well. |
@marcysutton existing aria tags won't be overwritten if they already exist now. @btford I am looking at how to write benchmarks now. Is there any particular part of the code that you want to focus on? |
It is great to see angular improving its accessibility for AT users. It's unclear, from my reading of the code, if the keyboard behaviours associated with the roles being added are also being built-in. For example, if a role=button is being used on a <div> it is imperative that the control is included in the focus order and can be activated using both the enter and space keys. If this is not the case then the addition of a role can degrade the user experience. |
@stevefaulkner that is such a good point! We definitely need to factor in tabIndex for the module to be useful. Thanks for the heads up. |
The ARIA design patterns documents required role/state/properties and keyboard interaction for a heap of custom controls. |
@arbus this module should also handle tabIndex. There are some obvious places, such as |
@btford @ThomasBurleson All the digest calls have been changed to use @marcysutton, I just added As for the Also, do you think we should consider adding in a |
|
@stevefaulkner ah got it. Then we shouldn't add that as a default. |
@arbus DEFINITELY not on the For |
Adds various aria attributes to the built in directives. This module currently hooks into ng-show/hide, input, textarea button as a basic level of support for a11y. I am using this as a base for adding more tags into the mix for form direction flow, making ng-repeat updates atomic but the tags here are the most basic ones. Closes angular#5486 and angular#1600
@marcysutton |
@arbus - ngAria is really great work! |
02dc2aa
to
fd2d6c0
Compare
@marcysutton So you mean if a person tabs into an item with |
@arbus @marcysutton I paired with @tbosch on this yesterday. Made some changes, but I think it's ready to land. I squashed my changes into @arbus's commit, and created a new PR at #9157. I'd be happy to keep iterating on it once it's in master, but we need to get this in soon for 1.3. Going forward, we can add new features to this module, but keep them disabled by default so they aren't breaking. |
I landed this as d1434c9 with some changes! 💃 @marcysutton @arbus @ThomasBurleson @stevefaulkner thanks so much for your input! If there are more things we should add, can we start threads in new issues to discuss building upon what we have here? |
Would this override something like ngTouch's touch supported ng-click? |
@david-driscoll nope |
Adds various aria attributes to the built in directives.
This module currently hooks into ng-show/hide, input, textarea
button as a basic level of support for a11y. I am using this as a
base for adding more tags into the mix for form direction flow,
making ng-repeat updates atomic but the tags here are the most
basic ones.
Closes #5486 and #1600