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

onRestored with bs4Dash #380

Open
gueguettecmoi opened this issue Jul 16, 2024 · 1 comment
Open

onRestored with bs4Dash #380

gueguettecmoi opened this issue Jul 16, 2024 · 1 comment

Comments

@gueguettecmoi
Copy link

In the context of a bookmarking application, the onRestored callback does not seem to work.

Here is an example of the application from the README without bas4Dash:

library(shiny)

ui <- function(requests) {
  fluidPage(
    fluidRow(
      plotOutput("plot1", height = 250),
      title = "Controls",
      sliderInput("slider", "Number of observations:", 1, 100, 50)
    )
  )
}

server <- function(input, output, session) {
  set.seed(122)

  # Bookmarking
  observe({
    reactiveValuesToList(input)
    session$doBookmark()
  })
  onBookmarked(updateQueryString)
  onRestored(function(state) {
    showNotification("Hello")
  })

  histdata <- rnorm(500)
  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
    hist(data)
  })
}

shinyApp(ui, server, enableBookmarking = 'url')

The showNotification function is properly called during a restoration. This is no longer the case after adding the bs4Dash elements

library(bs4Dash)

ui <- function(requests) {
  dashboardPage(
    dashboardHeader(title = "Basic dashboard"),
    dashboardSidebar(),
    dashboardBody(
      fluidRow(
        box(plotOutput("plot1", height = 250)),
        box(
          title = "Controls",
          sliderInput("slider", "Number of observations:", 1, 100, 50)
        )
      )
    )
  )
}

server <- function(input, output, session) {
  set.seed(122)

  observe({
    reactiveValuesToList(input)
    session$doBookmark()
  })
  onBookmarked(updateQueryString)
  onRestored(function(state) {
    showNotification("Hello")
  })

  histdata <- rnorm(500)
  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
    hist(data)
  })
}

shinyApp(ui, server, enableBookmarking = 'url')
@gueguettecmoi
Copy link
Author

Sorry seems to be the same as #177

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