Skip to content

fix(toolbar): eliminate duplicate id in toolbar_input_select() - #1351

Merged
gadenbuie merged 13 commits into
mainfrom
fix/toolbar-select-duplicate-ids
Aug 21, 2026
Merged

fix(toolbar): eliminate duplicate id in toolbar_input_select()#1351
gadenbuie merged 13 commits into
mainfrom
fix/toolbar-select-duplicate-ids

Conversation

@gadenbuie

Copy link
Copy Markdown
Member

Fixes #1350

Summary

toolbar_input_select() was generating HTML with duplicate id attributes on both the container div and the inner select element. This violates HTML standards and can cause issues with JavaScript 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 Shiny's input binding system. The label's for attribute is updated to point to the new select ID.

Verification

Before the fix, toolbar_input_select("select", label = "Choose", choices = c("A", "B")) produced:

<div id="select" class="bslib-toolbar-input-select shiny-input-container">
  <label id="select-label" for="select">...</label>
  <select id="select">...</select>  <!-- duplicate id! -->
</div>

After the fix, it produces:

<div id="select" class="bslib-toolbar-input-select shiny-input-container">
  <label id="select--label" for="select--select">...</label>
  <select id="select--select">...</select>  <!-- unique id -->
</div>

gadenbuie and others added 11 commits August 21, 2026 11:20
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
@gadenbuie
gadenbuie marked this pull request as ready for review August 21, 2026 15:33
@gadenbuie
gadenbuie requested a review from cpsievert August 21, 2026 15:37
@CLAassistant

This comment was marked as resolved.

@gadenbuie
gadenbuie merged commit 48abc60 into main Aug 21, 2026
@gadenbuie
gadenbuie deleted the fix/toolbar-select-duplicate-ids branch August 21, 2026 15:57
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.

toolbar_input_select() creates duplicate element IDs

3 participants