I want to check some user inputted data, testing some conditions and alerting via modalDialog() to get more user input (e.g. prompt X is NA; is this correct? Y/N).
However, I have found that if I put multiple showModal(modalDialogFunction()) calls in an observeEvent, only the last one will be evaluated for the user in that the modal pops up, etc. The print statements verify the conditions are met.
How can I execute sequential modals in this or a similar format?
Single file app: play around with numericInput()s to see how modals are executed.
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
numericInput("first", label="First", value=0),
numericInput("second", label="Second", value=0)
),
mainPanel(
actionButton("click", label="Click")
)
)
)
server <- function(input, output) {
firstModal <- function(){
modalDialog(
p("First is greater than zero"),
actionButton("clickHere", label="Click to continue")
)
}
secondModal <- function(){
modalDialog(
p("Second is greater than zero"),
actionButton("clickAgain", label="Click to continue again")
)
}
observeEvent(input$click, {
if(input$first>0){
print("First is greater than 0")
showModal(firstModal())
}
if(input$second>0){
print("Second is greater than 0")
showModal(secondModal())
}
})
}
shinyApp(ui = ui, server = server)