Hello- I have a shiny app where i want to conditionally display a modalDialog() depending on a logical test, to be tested within a call to observeEvent().
Unfortunately, observeEvent() doesn't seem to test the truth of the my logical (ie, "input$test2 != the_user" in the code below), and I seem to be missing something crucial about how to observe a shiny event.
here is a reprex; note the modal dialog is deployed ANY time the the checkbox changes and not the desired when the logical statement is true:
library(shiny)
the_user <- FALSE
ui <- fluidPage(
checkboxInput("test2", label = "test2"),
verbatimTextOutput("test2"),
verbatimTextOutput("user_opt")
)
server <- function(input, output, session) {
output$user_opt <- renderPrint({the_user})
output$test2 <- renderPrint(paste("the checkbox: ", input$test2))
observeEvent(input$test2 != the_user, {
showModal(modalDialog(
title = "my message",
"This should only appear when the checkbox is TRUE, given that the_user is FALSE"
))
})
}
shinyApp(ui, server)
any help is very appreciated