Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling show_toast before previous toast disappears causes "Duplicate IDs found" error to appear #702

Open
Silentstrike46 opened this issue Jul 26, 2024 · 0 comments

Comments

@Silentstrike46
Copy link

Calling shinyWidgets::show_toast while an existing toast is being displayed while devmode is active causes errors to appear due to duplicate Input/Output IDs being found.

Repex triggering error (Reduced from example code in documentation for show_toast):

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  actionButton(
    inputId = "info",
    label = "Show info toast",
    icon = icon("info")
  )
)

server <- function(input, output, session) {
  observeEvent(input$info, {
    show_toast(
      title = "Heads up",
      text = "Just a message",
      type = "info",
      position = "top-end",
      timer = 10000
    )
  })
}

if (interactive()) {
  shiny::devmode(TRUE)
  shinyApp(ui, server)
}

Error message:

Duplicate input/output IDs found
The following IDs were repeated:
- "swal2-select": x inputs
- "swal2-checkbox": x inputs
- "swal2-textarea": x inputs

where x increases each time it is called.

Example video of reprex above triggering error:
https://github.com/user-attachments/assets/e7dd0249-5d7e-4a3e-961c-a11a202eb6f4

As it stands I can't find a good way to close an existing toast via code, nor a good way to avoid this error (other than not spawning a second toast while another toast exists, which is inconvenient).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant