Skip to content

Add aria-labelledby to tab panels - #1365

Open
shelbylevel wants to merge 3 commits into
rstudio:mainfrom
shelbylevel:tab-panel-aria-labelledby
Open

shelbylevel wants to merge 3 commits into
rstudio:mainfrom
shelbylevel:tab-panel-aria-labelledby

Conversation

@shelbylevel

Copy link
Copy Markdown
Contributor

Description

Adds an id to each generated tab control and uses that ID for aria-labelledby on its associated tab panel.

Previously, generated tab panels had IDs and their tabs referenced those panels through href and aria-controls, but the tab controls themselves did not have IDs. As a result, the panels could not reference the tabs that label them.

The generated relationship is now:

<a
  id="tab-example-1-tab"
  href="#tab-example-1"
  aria-controls="tab-example-1"
>
  First
</a>

<div
  id="tab-example-1"
  aria-labelledby="tab-example-1-tab"
>
  First content
</div>

The tab ID is derived from the existing panel ID by appending -tab.

Testing

Added regression coverage verifying that:

  • tab controls receive unique IDs
  • href and aria-controls continue to reference the associated panel
  • aria-labelledby references the associated tab
  • subsequent tabs receive independent IDs and references
  • hidden tab panels retain their tab/panel relationship

devtools::test(filter = "navs-legacy") passes with 46 tests and no failures or warnings.

I also ran the full devtools::test() suite. The navs-legacy tests pass.
The remaining local failures were unrelated snapshot differences in
zzzz-bs-sass and page.

Related work

rstudio/shiny#4476 tracks keeping these ID/IDREF relationships synchronized when Shiny replaces temporary IDs during dynamic tab insertion.

Fixes #1364.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buildTabset() tab controls lack IDs needed for tab panel aria-labelledby

1 participant