Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

* Navsets created with an `id` (e.g. `navset_tab(id = "tabs")`) now use that `id` as their `data-tabsetid`, so their tab panes get stable `tab-tabs-1` style DOM ids instead of ones derived from a random integer. This makes the rendered markup reproducible across renders and easier to target from custom CSS and JavaScript. Navsets without an `id`, and `nav_menu()` dropdowns, keep the random ID. (#1342)

* Added an aria-controls attribute when using bslib::page_navbar() with bslib::nav_panel() to establish an explicit relationship between the tab and the controlled tab panel. (@shelbylevel, #1354)

# bslib 0.12.0

## New features
Expand Down
1 change: 1 addition & 0 deletions R/navs-legacy.R
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ liTag <- function(id, title, value, icon) {
# data-bs-* is for BS5+
`data-bs-toggle` = "tab",
`data-value` = value,
`aria-controls` = id,
disabled = if (is_hidden) NA,
icon,
title
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-navs-legacy.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ test_that("a tabset with an id uses it as the tabset id", {
expect_equal(tabset_ids_of(x), c("my_tabs", "my_tabs"))
expect_true(grepl('id="tab-my_tabs-1"', html, fixed = TRUE))
expect_true(grepl('href="#tab-my_tabs-1"', html, fixed = TRUE))
expect_true(grepl('aria-controls="tab-my_tabs-1"', html, fixed = TRUE))
})

test_that("a tabset with an id renders identically every time", {
Expand Down
Loading