question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A11y [Tabset]: incorrect ARIA attributes and roles

See original GitHub issue

Bug description:

ngb-tab uses semantically incorrect aria-expanded attribute for tabs: https://ng-bootstrap.github.io/#/components/tabset/examples

image

<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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
asapachcommented, Jul 17, 2019

On that one, I disagree, I think we do want the tabs to be announced as tabs ! 😄

Sorry, I’ve omitted it the second time. If you’re curios, NVDA on Firefox currently announces it as:

Simple tab selected expanded 1 of 1

And it should be:

Simple tab selected 1 of 3

1reaction
benouatcommented, Jul 17, 2019

The Bootstrap JavaScript is correctly using aria-selected in this case, which is a regression for ng-bootstrap.

I agree, and we should fix. #3292 is there for that.

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”:

On that one, I disagree, I think we do want the tabs to be announced as tabs ! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

ARIA: tab role - Accessibility - MDN Web Docs - Mozilla
The ARIA tab role indicates an interactive element inside a tablist ... Otherwise, their aria-selected attribute should be set to false .
Read more >
Background: An in-depth guide to ARIA roles - The A11Y Project
The ARIA specification is divided into categories of attributes, one of which is Roles, and the other being States & Properties. ARIA roles...
Read more >
How Not To Misuse ARIA States, Properties and Roles
Unfortunately, there is a lot of incorrect use of ARIA, read this post for best practices on how to use ARIA attributes properly....
Read more >
WAI-ARIA: Role=Tab - DigitalA11Y
In either case, authors SHOULD ensure that a selected tab has its aria-selected attribute set to true, that inactive tab elements have their ......
Read more >
Using ARIA - W3C
It is inappropriate to cite this document as other than work in ... 2.14 Aria Roles and Properties Not Available as Features in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found