Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reversed logic for named-list input in inputSweetAlert in "select"-mode #676

Open
splendiduser opened this issue Mar 14, 2024 · 0 comments

Comments

@splendiduser
Copy link

I use named lists to make pickerInput or virtualSelectInput show different names for selectable items than what is output after selection. I noticed that inputSweetAlert reverses what is being used for the displayed items and the selected options. Modifying the example given with inputSweetAlert to compare the two input methods using the same named list:

library(shiny)
library(shinyWidgets)
choices <- c(Banana = "item1" , Orange = "item2", Apple = "item3")

ui <- fluidPage(
  tags$h1("Input sweet alert"),
  virtualSelectInput(
    "virtualselect",
    label = "test",
    choices = choices
  ),
  verbatimTextOutput(outputId = "virtualselect_output"),
  actionButton("btn_select", "Select Input"),
  verbatimTextOutput(outputId = "sweetalert_output")
)
server <- function(input, output, session) {
  
  observeEvent(input$btn_select, {
    inputSweetAlert(
      session = session,
      "myselect",
      input = "select",
      inputOptions = choices,
      title = "What's your favorite fruit ?"
    )
  })
  output$sweetalert_output <- renderPrint(input$myselect)
  
  output$virtualselect_output <- renderPrint(input$virtualselect)
}

shinyApp(ui = ui, server = server)
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

No branches or pull requests

1 participant