shiny
shiny copied to clipboard
Shiny can create HTML with duplicated IDs because of shinyInputLabel's automatic ID
In this line https://github.com/rstudio/shiny/blob/b52b9e4520ad8d1e976299d5dec5e4ba3096bd04/R/input-utils.R#L7 an ID attribute is generated automatically. This results in a very real possibility of ending up with duplicate IDs.
Example:
h2(
id = "name-label",
"Student name",
textInput("name", "First name"),
textInput("lname", "Last name")
)
This generates the following HTML, which contains two "name-label" IDs. Perhaps duplicating IDs in label tags is considered to be good practice, but as far as I know assigning automatic IDs should be a big no-no because of this issue
<h2 id="name-label">
Student name
<div class="form-group shiny-input-container">
<label class="control-label" id="name-label" for="name">First name</label>
<input id="name" type="text" class="form-control" value=""/>
</div>
<div class="form-group shiny-input-container">
<label class="control-label" id="lname-label" for="lname">Last name</label>
<input id="lname" type="text" class="form-control" value=""/>
</div>
</h2>