Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

navset_card_pill, navset_card_tab, navset_card_underline ignore header arg #1024

Open
tanho63 opened this issue Mar 23, 2024 · 0 comments · May be fixed by #1028
Open

navset_card_pill, navset_card_tab, navset_card_underline ignore header arg #1024

tanho63 opened this issue Mar 23, 2024 · 0 comments · May be fixed by #1028

Comments

@tanho63
Copy link

tanho63 commented Mar 23, 2024

Describe the problem

navset_card_pill() and friends ignore its header argument (which seems to be intended to replicate the behaviour of navset_pill()).

Reprex

Given this example, I would expect HEADER CARD to appear somewhere, but it does not.

bslib::page_fluid(
  bslib::navset_card_pill(
    header = bslib::card("HEADER CARD"),
    bslib::nav_panel("Panel 1", bslib::card("panel 1 contents")),
    bslib::nav_panel("Panel 2", bslib::card("panel 2 contents"))
  )
)

image

Compare to what navset pill does:

bslib::page_fluid(
  bslib::navset_pill(
    header = bslib::card("HEADER CARD"),
    bslib::nav_panel("Panel 1", bslib::card("panel 1 contents")),
    bslib::nav_panel("Panel 2", bslib::card("panel 2 contents"))
  )
)

image

This problem seems to be caused here:

bslib/R/navs.R

Lines 53 to 81 in 3321ff1

items <- collect_nav_items(..., wrapper = wrapper)
pills <- navset_pill(
!!!items, id = id, selected = selected,
header = header, footer = footer
)
above <- match.arg(placement) == "above"
pillQ <- tagQuery(pills)
# https://getbootstrap.com/docs/5.0/components/card/#navigation
nav <- pillQ$children(".nav")$addClass(if (above) "card-header-pills")$selectedTags()[[1]]
content <- pillQ$children(".tab-content")$selectedTags()[[1]]
nav_args <- if (!is.null(title)) {
list(class = "bslib-navs-card-title", tags$span(title), nav)
} else {
list(nav)
}
card(
height = height,
full_screen = full_screen,
if (above) card_header(!!!nav_args),
navs_card_body(content, sidebar),
if (!above) card_footer(!!!nav_args)
)
}

The header is passed to navset_pill, then the nav + content components are pulled out via tagQuery without also bringing along the header/footer. Maybe what should be happening here is that the header and footer get passed directly to the final "card", either

  pills <- navset_pill(
    !!!items, id = id, selected = selected
  )
  # ... {extract pill header / content}
  card(
    height = height,
    full_screen = full_screen,
    if (above) card_header(!!!nav_args),
    header,
    navs_card_body(content, sidebar),
    footer,
    if (!above) card_footer(!!!nav_args)
  )

or (maybe weirder?)

  pills <- navset_pill(
    !!!items, id = id, selected = selected
  )
  # ... {extract pill header / content}
  card(
    height = height,
    full_screen = full_screen,
   # somehow put header into card_header rather than below card_header
    if (above || !is.null(header)) card_header(if (above) !!!nav_args, header)
    navs_card_body(content, sidebar)
  )

I think the former solution is probably better and can make a PR to that effect, if desired?

Session Info

session info
R> sessioninfo::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.2 (2023-10-31)
 os       Ubuntu 22.04.4 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  en_CA.UTF-8
 ctype    en_CA.UTF-8
 tz       America/Toronto
 date     2024-03-23
 rstudio  2023.09.1+494 Desert Sunflower (desktop)
 pandoc   2.9.2.1 @ /usr/bin/pandoc

─ Packages ──────────────────────────────
 package     * version    date (UTC) lib source
 bslib         0.6.2.9000 2024-03-23 [1] Github (rstudio/bslib@3321ff1)
 cachem        1.0.8      2023-05-01 [1] RSPM
 callr         3.7.3      2022-11-02 [1] RSPM
 cli           3.6.1      2023-03-23 [1] RSPM
 crayon        1.5.2      2022-09-29 [1] RSPM
 devtools    * 2.4.5      2022-10-11 [1] RSPM
 digest        0.6.33     2023-07-07 [1] RSPM
 ellipsis      0.3.2      2021-04-29 [1] RSPM
 fansi         1.0.5      2023-10-08 [1] RSPM
 fastmap       1.1.1      2023-02-24 [1] RSPM
 fs            1.6.3      2023-07-20 [1] RSPM
 glue          1.6.2      2022-02-24 [1] RSPM
 htmltools     0.5.7.9000 2024-03-23 [1] Github (rstudio/htmltools@30d13a1)
 htmlwidgets   1.6.3      2023-11-22 [1] RSPM
 httpuv        1.6.12     2023-10-23 [1] RSPM
 jquerylib     0.1.4      2021-04-26 [1] RSPM
 jsonlite      1.8.7      2023-06-29 [1] RSPM
 knitr         1.45       2023-10-30 [1] RSPM
 later         1.3.1      2023-05-02 [1] RSPM
 lifecycle     1.0.4      2023-11-07 [1] RSPM
 magrittr      2.0.3      2022-03-30 [1] RSPM
 memoise       2.0.1      2021-11-26 [1] RSPM
 mime          0.12       2021-09-28 [1] RSPM
 miniUI        0.1.1.1    2018-05-18 [1] RSPM
 pillar        1.9.0      2023-03-22 [1] RSPM
 pkgbuild      1.4.2      2023-06-26 [1] RSPM
 pkgconfig     2.0.3      2019-09-22 [1] RSPM
 pkgload       1.3.3      2023-09-22 [1] RSPM
 prettyunits   1.2.0      2023-09-24 [1] RSPM
 processx      3.8.2      2023-06-30 [1] RSPM
 profvis       0.3.8      2023-05-02 [1] RSPM
 promises      1.2.1      2023-08-10 [1] RSPM
 ps            1.7.5      2023-04-18 [1] RSPM
 purrr         1.0.2      2023-08-10 [1] RSPM
 R6            2.5.1      2021-08-19 [1] RSPM
 Rcpp          1.0.11     2023-07-06 [1] RSPM
 remotes       2.4.2.1    2023-07-18 [1] RSPM
 rlang         1.1.2      2023-11-04 [1] RSPM
 rstudioapi    0.15.0     2023-07-07 [1] RSPM
 sass          0.4.9      2024-03-15 [1] RSPM
 sessioninfo   1.2.2      2021-12-06 [1] RSPM
 shiny       * 1.8.0      2023-11-17 [1] RSPM
 stringi       1.8.2      2023-11-23 [1] RSPM
 stringr       1.5.1      2023-11-14 [1] RSPM
 tibble        3.2.1      2023-03-20 [1] RSPM
 urlchecker    1.0.1      2021-11-30 [1] RSPM
 usethis     * 2.2.2      2023-07-06 [1] RSPM
 utf8          1.2.4      2023-10-22 [1] RSPM
 vctrs         0.6.4      2023-10-12 [1] RSPM
 withr         2.5.2      2023-10-30 [1] RSPM
 xfun          0.41       2023-11-01 [1] RSPM
 xtable        1.8-4      2019-04-21 [1] RSPM

 [1] /home/tan/R/x86_64-pc-linux-gnu-library/4.3
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

──────────────────────────
@tanho63 tanho63 changed the title navset_card_pill(), navset_card_tab, navset_card_underline ignore header arg navset_card_pill, navset_card_tab, navset_card_underline ignore header arg Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant