Skip to content

bugfix: updateSelectInput handle correctly named list as choices#464

Merged
TymekAppsilon merged 5 commits intoAppsilon:developfrom
DangerousWizardry:patch-1
Dec 2, 2025
Merged

bugfix: updateSelectInput handle correctly named list as choices#464
TymekAppsilon merged 5 commits intoAppsilon:developfrom
DangerousWizardry:patch-1

Conversation

@DangerousWizardry
Copy link
Contributor

Correct a bug where value is not correctly attributed to the data-value attribute in semantic selectInput when using named list as choices.

Have you read the Contributing Guidelines?

Description

Fix a bug when you use named list as choices list. jsonlite::toJSON badly handle the choices list when it came to R named list. Shiny expect a simple JS array. To do that we just have to unname & unlist the initial choices list to get a value vector.

Definition of Done

  • The change is thoroughly documented.
  • The CI passes (R CMD check, linter, unit tests, spelling).
  • Any generated files have been updated (e.g. .Rd files with roxygen2::roxygenise())

Correct a bug where value is not correctly attributed to the data-value attribute in semantic selectInput when using named list as choices.
@TymekDev
Copy link
Contributor

Hi, thank you for your contribution! Two questions:

  1. Do you happen to have a reproducible example to test the change?
  2. Do you know if update_dropdown_input() has some discrepancies too?

@DangerousWizardry
Copy link
Contributor Author

Here you'll find a reproducible example.
It seems to come from named list including spaces in their names.

library(shiny)
library(shiny.semantic)


ui <- semanticPage(
  title = "My page",
  shiny.semantic::selectInput(
    inputId = "item_picker",
    label = "Choose your item",
    choices =  list()
  )
    
)


server <- function(input, output, session) {
  
  
  
observe({
  item_list <- list("my first item" = 1,"my second item" = 2)
  shiny.semantic::updateSelectInput(session,
                          inputId = "item_picker",
                          label = "Choose your item",
                          choices =  item_list,
                          selected = 2)
})

}

# Run the application 
shinyApp(ui = ui, server = server)

Copy link
Contributor

@TymekAppsilon TymekAppsilon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Sorry, for the hold up.

@TymekAppsilon TymekAppsilon merged commit 9a85a03 into Appsilon:develop Dec 2, 2025
5 checks passed
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.

3 participants