RinteRface/bs4Dash

onRestored with bs4Dash

Opened this issue · 1 comments

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')

Sorry seems to be the same as #177