1

I have created a modal that is activated when the app is launched and warns the user that he first needs to upload an excel file. But when I upload it the modal is displayed again which seems to be wrong.

library(shiny)
library(shinyalert)

ui <- fluidPage(
  useShinyalert(),  # Set up shinyalert
  fileInput('file1', 'Choose xls file',
            accept = c(".xls")
  )
)

server <- function(input, output, session) {
  observeEvent(is.null(input$file1), {
    # Show a modal when the button is pressed
    shinyalert("Oops!", "Something went wrong.", type = "error")
  })
}

shinyApp(ui, server)
firmo23
  • 7,490
  • 2
  • 38
  • 114

1 Answers1

1

Perhaps you can try with an if condition.

observeEvent(input$file1, {
    if (is.null(input$file1))
    # Show a modal when the button is pressed
    shinyalert("Oops!", "Something went wrong.", type = "error")
  }, ignoreNULL = FALSE)
YBS
  • 19,324
  • 2
  • 9
  • 27
  • thanks could you look at this shiny issue too? https://stackoverflow.com/questions/71023022/create-a-dynamic-table-on-shiny-app-based-on-shiny-widget-and-row-selection-of-a – firmo23 Feb 08 '22 at 01:54