ngAria should check for interactive child elements before binding role=button and tabindex=0 #14672
Description
I've seen this bug in the wild on a large web application using ngAria: ng-click
tries to help accessibility by binding role="button"
and tabindex="0"
, unless opted out. The problem is if that DIV with an ng-click
wraps another interactive element such as <button>
or <a>
, the extra tabindex
and role
cause problems.
Current behavior
tabindex="0"
on everything causes keyboard hell with often-redundant tab stops; and the role=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 off tabindex="0"
and role="button"
. The DIV with ng-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.