Open benubah opened 8 months ago
- I cannot restore the state of the app to the
nav_panel
of my choice (which isTwo
in the reprex below). The app always restores to the firstnav_panel
,One
.
I have used a navset_bar
in combination with page_fluid
instead of page_navbar
to solve this since page_navbar
does not have an id
argument.
Thanks for the report and the reprex @benubah! I'll open a new issue for the page_navbar()
bookmarking problem.
I can reproduce the issues with bookmarking inputs inside accordions. Here's a slightly smaller and more minimal reprex:
library(shiny)
library(bslib)
accordion_filters <- accordion(
accordion_panel(
"Filters",
selectInput(
inputId = "first_choice",
label = "First choice",
choices = c("A","B","C","D")
),
textInput("reason", "I like this choice because...")
)
)
ui <- function(request) {
page_sidebar(
title = "My App",
sidebar = sidebar(
open = "always",
accordion_filters,
selectInput("second_choice", "Second choice", rev(LETTERS)[1:4]),
bookmarkButton()
),
uiOutput("your_choice")
)
}
server <- function(input, output, session) {
output$your_choice <- renderUI({
markdown(
sprintf(
"Your first choice was `%s` and your second choice is `%s`. You chose `%s` because %s.",
input$first_choice,
input$second_choice,
input$first_choice,
input$reason
)
)
})
}
shinyApp(ui, server, enableBookmarking = "url")
Change all of the inputs and use the bookmark button to create a new link. When you load the bookmarked app, the inputs outside of the accordion are updated to the bookmarked state as expected, but the inputs inside the accordion panel are not.
thanks @gadenbuie !
The problem is not from the accordion because I have now realized that I can pass the accordion code straight into the sidebar
and it works. Please see reprex below. But storing the accordion
in a variable and then passing that variable (accordion_filters
) to the sidebar
is what does not work.
library(shiny)
library(bslib)
ui <- function(request) {
page_sidebar(
title = "My App",
sidebar = sidebar(
open = "always",
accordion(
accordion_panel(
"Filters",
selectInput(
inputId = "first_choice",
label = "First choice",
choices = c("A","B","C","D")
),
textInput("reason", "I like this choice because...")
)
),
selectInput("second_choice", "Second choice", rev(LETTERS)[1:4]),
bookmarkButton()
),
uiOutput("your_choice")
)
}
server <- function(input, output, session) {
output$your_choice <- renderUI({
markdown(
sprintf(
"Your first choice was `%s` and your second choice is `%s`. You chose `%s` because %s.",
input$first_choice,
input$second_choice,
input$first_choice,
input$reason
)
)
})
}
shinyApp(ui, server, enableBookmarking = "url")
The problem
Hi, while testing shiny bookmarking using
bslib
, I encountered the following issues:bslib
when myselectizeInput
is inside anaccordion
- the state of the inputs are not restored. But outside anaccordion
, the state of theselectizeInput
is restored using theurl
.nav_panel
of my choice (which isTwo
in the reprex below). The app always restores to the firstnav_panel
,One
.Session Info