A11y [Tabset]: incorrect ARIA attributes and roles
See original GitHub issueBug description:
ngb-tab
uses semantically incorrect aria-expanded
attribute for tabs: https://ng-bootstrap.github.io/#/components/tabset/examples
<ngb-tabset>
<ul role="tablist" class="nav nav-tabs justify-content-start">
<li class="nav-item">
<a class="nav-link active" href="" role="tab"... aria-expanded="true" aria-disabled="false">
Simple
</a>
</li>
...
</ul>
Screen readers will announce tabs as either “collapsed” or “expanded” which make no sense, because aria-expanded
should be used for collapsible content like accordions.
ARIA guidelines recommend using aria-selected
attribute instead: https://www.w3.org/TR/wai-aria-practices/examples/tabs/tabs-2/tabs.html
The Bootstrap JavaScript is correctly using aria-selected
in this case, which is a regression for ng-bootstrap.
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" href="#home" role="tab" ... aria-selected="true">
Home
</a>
</li>
...
</ul>
This was raised during the initial PR review, but consequently ignored.
Also, since <ul>
is used as role=tablist
, the list items need to be excluded from the accessibility tree so that screen readers would ignore their semantic role.
Currently the tabs are announced as “tab 1 of 1”, but if you add role=none
to <li>
it will be announced as “1 of 3”:
<ngb-tabset>
<ul role="tablist" class="nav nav-tabs justify-content-start">
<li class="nav-item" role="none">
<a class="nav-link active" href="" role="tab"... aria-selected="true" aria-disabled="false">
Simple
</a>
</li>
...
</ul>
Link to minimally-working StackBlitz that reproduces the issue:
https://ng-bootstrap.github.io/stackblitzes/tabset/basic/stackblitz.html
Versions of Angular, ng-bootstrap and Bootstrap:
Angular: 7.x or 8.x
ng-bootstrap: 4.x or 5.x
Bootstrap: 4.x
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top GitHub Comments
Sorry, I’ve omitted it the second time. If you’re curios, NVDA on Firefox currently announces it as:
And it should be:
I agree, and we should fix. #3292 is there for that.
On that one, I disagree, I think we do want the tabs to be announced as tabs ! 😄