I’m working on an app which uses modalDialogs, one for accepting T+Cs and one for a message box displayed at a click of a button. The first modalDialog is a splash screen that is coded in ui.R and displayed on start-up.
The 2nd is activated with a click of a button in the server function. However, when you press the button it displays the first message and not the second – see attached reproducible example!
If I comment out the first ModalDialog (“modalDialog(h3("This is the 1st ModalDialog…...”, etc) in the UI then the button behaves as expected!
Is this a bug or am I doing something stupid here?
library(shiny)
ui <- fluidPage(
titlePanel("Multiple Modal Dialog Example Issue App"),
mainPanel(
modalDialog(h3("This is the 1st ModalDialog"),title = "This is the 1st ModalDialog", size = "l", easyClose = FALSE),
actionButton("goButton", "Display New ModalDialog", class = "btn-success")
)
)
server <- function(input, output) {
observeEvent(input$goButton,{
showModal(modalDialog(h3("This is the 2nd ModalDialog"),title = "This is the 2nd ModalDialog", size = "l", easyClose = FALSE))
}
)
}
shinyApp(ui = ui, server = server)
Many thanks nirgrahamuk this looks to work although I'm not sure why the issue arose in the first place. Do you think this a bug or the intended behaviour? If the former, I may add this as an issue on https://github.com/rstudio/shiny/issues