Closed mark-druffel closed 2 years ago
Seems as if fluidPage doesn't (properly) inherit theme of navbarPage and jumps back to default (BS version < 5) at dependency check? One way to solve this as application designer would be to set theme for fuildPage as well.
However... updatePickerInput still seems to be broken:
library(shiny)
library(shinyWidgets)
library(bslib)
ui <- navbarPage(
theme=bs_theme(version = 5, bootswatch = "default"),
title = "example",
tabPanel(h4("tab1"),
fluidPage(
theme=bs_theme(version = 5, bootswatch = "default"),
sidebarLayout(
sidebarPanel(
shinyWidgets::pickerInput(
inputId = "cars",
label = "Car (picker)",
multiple = FALSE,
choices = sort(rownames(mtcars))
)
),
mainPanel(verbatimTextOutput("value"))
)
))
)
server <- function(input, output,session) {
output$value <- renderPrint({
input$cars
})
# --> broken
# shinyWidgets::updatePickerInput(
# session=session,
# inputId = "cars",
# clearOptions = TRUE,
# choices = rownames(mtcars)
# )
}
shinyApp(ui, server)
Seems as if fluidPage doesn't (properly) inherit theme of navbarPage and jumps back to default (BS version < 5) at dependency check? One way to solve this as application designer would be to set theme for fuildPage as well.
However... updatePickerInput still seems to be broken:
library(shiny) library(shinyWidgets) library(bslib) ui <- navbarPage( theme=bs_theme(version = 5, bootswatch = "default"), title = "example", tabPanel(h4("tab1"), fluidPage( theme=bs_theme(version = 5, bootswatch = "default"), sidebarLayout( sidebarPanel( shinyWidgets::pickerInput( inputId = "cars", label = "Car (picker)", multiple = FALSE, choices = sort(rownames(mtcars)) ) ), mainPanel(verbatimTextOutput("value")) ) )) ) server <- function(input, output,session) { output$value <- renderPrint({ input$cars }) # --> broken # shinyWidgets::updatePickerInput( # session=session, # inputId = "cars", # clearOptions = TRUE, # choices = rownames(mtcars) # ) } shinyApp(ui, server)
obsaditelnost I could be misunderstanding your point, but I changed my code from above to version 4 and see bs version 4 in the browser. Either way, I think my issue relates to pickerInput, not bslib, at least as far as I can tell 🤷
Version 4 Code:
library(shiny)
library(shinyWidgets)
library(dplyr)
library(bslib)
library(reactable)
# UI ####
app_ui <- function(){
bslib::page_navbar(
id = "navbar",
header = shiny::tags$style(
HTML("
#filtersPanel {
padding: 0 20px 20px 20px;
background-color: white;
opacity: 0.65;
zoom: 0.8;
transition: opacity 500ms 1s;
z-index: 9999;
}
#filtersPanel:hover {
opacity: 0.95;
transition-delay: 0;
}"
)
),
theme = bslib::bs_theme(
version =4,
bootswatch = "default"
),
bslib::nav(
title = "Dashboard",
bslib::page_fluid(
shiny::absolutePanel(
id = "filtersPanel",
fixed = T,
draggable = T,
top = 75, left = "auto", right = 20, bottom = "auto",
width = 330, height = "auto",
shiny::h3("Filters"),
shinyWidgets::pickerInput(
inputId = "cars",
label = "Car (picker)",
multiple = T,
choices = sort(rownames(mtcars)),
selected = rownames(mtcars),
options = shinyWidgets::pickerOptions(
actionsBox = TRUE,
liveSearch = T
)
)
),
reactable::reactableOutput("tbl")
)
)
)
}
# Server ####
app_server <- function(input, output, session) {
output$tbl <- reactable::renderReactable({
mtcars |>
tibble::rownames_to_column("car") |>
dplyr::filter(car %in% input$cars) |>
reactable::reactable()
})
}
# Run ####
shiny::shinyApp(
ui = app_ui,
server = app_server,
options = list(),
enableBookmarking = NULL
)
Hello,
Yes I see an issue with shiny::absolutePanel()
and Bootstrap 5, thanks for reporting it.
I don't have a solution at the moment. Bootstrap 5 support for pickerInput()
is limited for the moment (only available in beta version here : https://github.com/snapappointments/bootstrap-select/releases). An alternative could be to use virtualSelectInput()
which has similar functionality.
For the second issue, you don't need fluidPage()
here, xxxPage()
functions shouyld only be used to initialized an UI and be used once by application. And for updatePickerInput()
it should work if you install development version of shinyWidgets.
@pvictor Thanks so much for the reply and all the info, I didn't realize fluidPage wasn't needed and appreciate the feedback there.
Regarding pickerInput, I had just used bootstrap 4 to make things work, but I didn't see virtualSelectInput() and agree it looks like a perfect substitute. Thanks so much for your help and for the amazing package, it's really made a huge difference for my app!
Hi there,
Thanks for this amazing package! I am experiencing an issue when I use pickerInput() inside an absolutePanel() with bootstrap 5. The dropdown does not open when I click it. I think this might be related to https://github.com/dreamRs/shinyWidgets/issues/460, but based on the latest it sounded like that had been resolved. I tested the pickerInput() using sidebarPanel and it works so it seems to be specific to absolutePanel.
When using pickerInput() inside absolute panel with bootstrap 4, the widget works as expected.
If I change the same code to bootstrap version 5 (line 27) the dropdown won't respond when I click it.