-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngAria should check for interactive child elements before binding role=button and tabindex=0 #14672
Comments
One problem I see is that this won't work for dynamically loaded content (templateUrl, ngInclude), but also for content that changes dynamically, like ngIf. |
That would also break usecase, where the tabindex/role are intended in the parent elements (for whatever reason). Indeed, taking dynamic elements into account, I feel that this would be too much magic to implement - and it wouldn't be possible to cover all usecases either. Better alternatives might be:
|
Those are really great points, thanks for the feedback. I agree that going up the DOM tree from interactive elements would be too costly. It would also be tough to know which attributes were added intentionally without keeping track of everything...again, a huge cost for a click handler. I like the idea of an attribute for opting out of ngAria on specific elements. I still think there will be a lot of |
I've seen this bug in the wild on a large web application using ngAria:
ng-click
tries to help accessibility by bindingrole="button"
andtabindex="0"
, unless opted out. The problem is if that DIV with anng-click
wraps another interactive element such as<button>
or<a>
, the extratabindex
androle
cause problems.Current behavior
tabindex="0"
on everything causes keyboard hell with often-redundant tab stops; and therole=button
wrapping other content confuses screen reader users.Here is a Plunker showing the wrapping interactive elements, prompted from #14665: https://plnkr.co/edit/SPxQ0X2RQvvfvAmDVTNA?p=preview
What is the expected behavior?
If we can do it fast enough, ngAria should test an
ng-click
target's child elements against the nodeBlacklist and return false on the first instance, leaving offtabindex="0"
androle="button"
. The DIV withng-click
will then stay a mouse-only element to prevent degrading accessibility in the rest of that DOM subtree.What is the motivation / use case for changing the behavior?
ngAria currently causes more problems than it solves with "fixes" like the one
ng-click
tried to solve. Addressing this problem would improve the utility of the library.Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
Visible in the latest version.
The text was updated successfully, but these errors were encountered: