Closed stla closed 6 months ago
You have a bit of a circular dependency with the output$content
and input$select_color
going on, which is causing this issue. If you want to update header based on the sidebar inputs, you could adopt a pattern like this one?
library(shiny)
library(bslib)
choices <- c("cyl", "disp")
ui <- page_navbar(
sidebar = "Sidebar",
fillable = FALSE,
nav_panel(
"Tab 1",
card(
wrapper = function(...) card_body(..., height = 300, max_height = 400),
full_screen = TRUE,
card_header(
uiOutput("card_header")
),
layout_sidebar(
sidebar = selectInput(
"select_color",
"Marker color",
choices = choices,
selected = choices[1]
),
"Main"
)
)
)
)
server <- function(input, output) {
Title <- reactiveVal("TITLE")
output$card_header <- renderUI({
Title()
})
observeEvent(input$select_color, {
if(input$select_color != choices[1])
Title("NEW TITLE")
})
}
shinyApp(ui = ui, server = server)
Yes, I know there's something bad, but this is just to give an (artifical) example. I didn't find a less artifical one (something more concrete which also causes the full screen to exit). Maybe any example showing this issue is artificial, I don't know actually.
I suppose if card()
gained an ability to go full-screen when rendered, it could help with your issue, but I'd still consider it an anti-pattern compared to the solution I offered. If someone wants to provide a clearer motivation for that as a feature, I'd be happy to give it more consideration
The bug here is that we're not exiting full screen mode when a full-screen card is removed from the page. In the reprex app, you can actually press Escape after the new card is added to clear the full screen state because the keyboard event listeners are still enabled.
This issue has been automatically locked. If you have found a related problem, please open a new issue (with a reproducible example or feature request) and link to this issue. :raising_hand: Need help? Connect with us on Discord or Posit Community.
Hello,
Look at the app below. Put the card in full-screen mode, then select
disp
in the dropdown. This causesuiOutput("content")
to re-render, and then the app exits from the full-screen mode. Then there is a problem: the full-screen icon of the card does no longer appear.System details
Output of
sessionInfo()
: