From 80da533c9a9d9203454c2d380b3d5bf590f62afd Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Fri, 21 Aug 2026 11:20:30 -0400 Subject: [PATCH 01/13] fix(toolbar): eliminate duplicate id in toolbar_input_select() The toolbar_input_select() function was creating duplicate element IDs by assigning the same id to both the outer container div and the inner select element. This violates HTML standards and can cause issues with selectors and accessibility tools. The fix assigns a distinct id to the select element using the pattern {id}--select (double dash to avoid conflicts with Shiny module inputs), while the container retains its id for the Shiny input binding. Updates the label's for attribute accordingly. Fixes #1350 --- R/toolbar.R | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/R/toolbar.R b/R/toolbar.R index d36243ca5..852b317ea 100644 --- a/R/toolbar.R +++ b/R/toolbar.R @@ -640,7 +640,7 @@ toolbar_input_select <- function( } select_tag <- tags$select( - id = id, + id = sprintf("%s--select", id), class = "form-select form-select-sm", `data-shiny-no-bind-input` = NA, processed$options @@ -657,10 +657,9 @@ toolbar_input_select <- function( ) label_elem <- tags$label( - # shiny::selectInput() append `-label` to id for the label `for` attribute - id = sprintf("%s-label", id), + id = sprintf("%s--label", id), class = "control-label", - `for` = id, + `for` = sprintf("%s--select", id), icon_elem, tags$span( class = "bslib-toolbar-label", From e407514339ae4870058d22261a8c02daca959667 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Fri, 21 Aug 2026 11:20:33 -0400 Subject: [PATCH 02/13] test(toolbar): update label for attribute expectation in toolbar_input_select() test --- tests/testthat/test-toolbar.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index 7e7f45cbb..bd7a87d71 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -301,7 +301,7 @@ test_that("toolbar_input_select() has proper label structure", { # Label should have for attribute pointing to select label_for <- htmltools::tagGetAttribute(label_elem, "for") - expect_equal(label_for, "select") + expect_equal(label_for, "select--select") # Find the label text span label_spans <- tagQuery(label_elem)$find( From bcca220db103f08cc05d3b97fab5d2a78513ff85 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Fri, 21 Aug 2026 11:20:36 -0400 Subject: [PATCH 03/13] docs(news): add entry for toolbar_input_select() duplicate id fix (#1350) --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index c565404a3..73fe9e6b2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,10 @@ * `show_offcanvas()` now accepts a character `id` to reveal a panel already in the UI, in addition to a `bslib_offcanvas` object. Previously, a bare string was treated as body content for a new anonymous panel; it is now treated as an id lookup instead, and errors if it looks like body text (e.g. it contains whitespace or is empty). `htmltools::HTML()` continues to be treated as body content. (#1346) +## Bug fixes + +* Fixed `toolbar_input_select()` creating duplicate element IDs by assigning the same ID to both the container div and the inner select element. The select element now receives a distinct ID using the pattern `{id}-select`. (#1350) + ## Improvements * 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) From f4721a9cf7d0495287944d781123a03650ffbc10 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Fri, 21 Aug 2026 11:20:39 -0400 Subject: [PATCH 04/13] test(toolbar): update snapshots for toolbar_input_select() id changes --- tests/testthat/_snaps/toolbar.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/testthat/_snaps/toolbar.md b/tests/testthat/_snaps/toolbar.md index 98c547131..b9b9a3ff1 100644 --- a/tests/testthat/_snaps/toolbar.md +++ b/tests/testthat/_snaps/toolbar.md @@ -178,11 +178,11 @@ choices = c("A", "B", "C"), tooltip = FALSE)) Output
-
@@ -195,11 +195,11 @@ tooltip = FALSE)) Output
-
@@ -212,11 +212,11 @@ tooltip = FALSE)) Output
-
@@ -227,11 +227,11 @@ show_raw_html(grouped_select) Output
-