ng-click should do some helpful accessibility things by default #9254
Description
I often see naive developers doing this:
<a href="" ng-click="...">Click me</a>
<div ng-click="...">Click me</div>
What would really be better is this:
<button ng-click="..." class="link">Click me</button>
<button ng-click="..." class="reset">Click me</button>
plus css styles to make the classes do the right thing.
However, it seems that this is too much to ask of developers. We are a lazy bunch and don't want to define new classes and reset styles for the sake of accessibility. To help folks out would be nice if ng-click
automatically assigned the correct accessibility attributes if not already specified (role="button" tabindex="0"
) and handle all the right input handling (e.g. pressing enter, spacebar) to communicate to assistive technology that this element is actually a button , unless a role is explicitly specified already.
This would likely increase code size a little bit, so maybe it makes sense to put this extra logic into the ngAria
module so that it is opt-in.