rstudio / rstudio/bslib

nav_insert has different classes than "native" nav_panel

Open
#1,222 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
569
Forks
72
Avg merge
1d 2h
Merged PRs (30d)
5

Description

I was trying to insert nav_panels into a navset and noticed that inserted panels are different than navsets that are there from the beginning.

In specific, the inserted nav panels miss the html-fill-item html-fill-container classes.

A MWE would be this:


library(shiny)
library(bslib)
d <- div(
  "A",
  style = "background: red; height: 100%"
)

ui <- page_fluid(
  actionButton("add", "Add 'Dynamic' tab"),
  actionButton("remove", "Remove 'Foo' tab"),
  navset_card_underline(
    height = "80vh",
    id = "tabs",
    nav_panel("Hello", d),
    nav_panel("Foo", d),
    nav_panel("Bar", d)
  )
)
server <- function(input, output) {
  observeEvent(input$add, {
    nav_insert(
      "tabs", target = "Bar", select = TRUE,
      nav_panel("Dynamic", d)
    )
  })
  observeEvent(input$remove, {
    nav_remove("tabs", target = "Foo")
  })
}
shinyApp(ui, server)

The original tabs (Hello, Foo, Bar) are all full-height.

Image

whereas the new dynamic panel is not full-height:

Image

Changing the nav_insert to

nav_insert(
  "tabs", target = "Bar", select = TRUE,
  fix_fullscreen(nav_panel("Dynamic", card_body(d))) 
)

the following function fixes it for me for the moment

fix_fullscreen <- function(x) {
  shiny::tagAppendAttributes(x, class = "html-fill-item html-fill-container")
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the nav_insert and nav_panel entry points and reproduce the provided Shiny MWE. Compare the classes on panels created initially with those inserted dynamically; done means inserted panels receive the same full-height behavior without the user's fix_fullscreen workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.