daattali / shinyalert

🗯️ Easily create pretty popup messages (modals) in Shiny
https://daattali.com/shiny/shinyalert-demo/
Other
241 stars 26 forks source link

`radioGroupButtons` inputs trigger closure of `shinyalert()` modals #65

Closed MokeEire closed 2 years ago

MokeEire commented 2 years ago

Interacting with shinyWidgets' radioGroupButtons() within a shinyalert() modal is closing the dialog box.
Below is the code for two inputs inside a shinyalert(), one using radioButtons() which will not cause the modal to close, and the other using radioGroupButtons() which will cause the modal to close.

Let me know if this is enough code to diagnose the issue. I am building a modular shiny app so I didn't want to share everything and overcomplicate things, but I can provide more context if necessary. The shinyalert is being called inside an observeEvent, which observes an actionButton.

shinyalert::shinyalert(
    title = "How many players?", 
    html = T, 
    showConfirmButton = F, 
    size = "m", 
    text = tagList(
      fluidRow(
        column(4, align = "center",
               # How many players
               h3("Team A"),
               radioButtons(
                 "A",
                 label = NULL,
                 choices = 2:4, 
                 selected = 2,
                 ),
               ),
        column(4, align = "center", offset = 4,
               # How many players
               h3("Team B"),
               shinyWidgets::radioGroupButtons(
                                               "B",
                                               label = NULL,
                                               choices = 2:4, 
                                               selected = 2,
                                               size = "lg"),
        )
      ),
      fluidRow(
        # - Continue
        column(2, offset = 10,
               actionButton("complete",
                            label = "Next")
        )
      )
daattali commented 2 years ago

Thanks for the report. There is a known issue in the underlying javascript library (maybe it's not widely known, but I've noticed it in the past) where any <button> tag triggers the modal to close. I just looked at shinyWidget's implementation of radio buttons and unfortunately it uses button tags, which is why this fails. I don't think this is fixable.

daattali commented 2 years ago

I added a note to the readme about this issue