rstudio / rstudio/bslib

Nested accordion not correctly interpreting `multiple` parameter value

Open
#819 1 comment 0 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

Description of Problem

When using bslib::accordion() and bslib::accordion_panel(), as below, I have an accordion with s (say s=3) panels. I want each of the accordion_panel objects to contain an accordion, which itself contains t (say t=2) panels. No problem constructing this, as below:

Upon initiation, all three panels and each of the nested accordions are closed. As requested on the outer/parent accordion, only one accordion panel is allowed to be open (multiple=FALSE), and this works well.

However, although each of the inner accordions also have multiple=FALSE, multiple panels within these inner accordions do open (i.e. the panels in the inner accordion do not automatically close when another panel within that inner accordion is selected).

Furthemore, if we set the inner accordion to multiple=TRUE, then the outer panel will close when clicking on a closed inner panel

library(shiny)
library(bslib)

accordion(
  accordion_panel(
    title = "panel_1",
    accordion(
      accordion_panel(title = "panel_1_sub_1", HTML("panel 1, subpanel 1 content")),
      accordion_panel(title = "panel_1_sub_2", HTML("panel 1, subpanel 2 content")),
      open=FALSE,
      multiple=FALSE # this is not working
      
    )
  ),
  accordion_panel(
    title = "panel_2",
    accordion(
      accordion_panel(title = "panel_2_sub_1", HTML("panel 2, subpanel 1 content")),
      accordion_panel(title = "panel_2_sub_2", HTML("panel 2, subpanel 2 content")),
      open=FALSE, 
      multiple=FALSE # this is not working
    )
  ),
  accordion_panel(
    title = "panel_3",
    accordion(
      accordion_panel(title = "panel_3_sub_1", HTML("panel 3, subpanel 1 content")),
      accordion_panel(title = "panel_3_sub_2", HTML("panel 3, subpanel 2 content")),
      open=FALSE, 
      multiple=TRUE # this is not working (closes parent panel)
    )
  ),
  open=FALSE, 
  multiple=FALSE # this is working fine
)
Session Info
─ Session info ────────────────────────────────────────────────
 setting  value
 version  R version 4.2.0 (2022-04-22 ucrt)
 os       Windows 10 x64 (build 19044)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/New_York
 date     2023-10-05
 rstudio  2022.02.2+485 Prairie Trillium (desktop)
 pandoc   2.12 @ C:\\Users\\<username>\\ANACON~1\\Scripts\\pandoc.exe

─ Packages ────────────────────────────────────────────────────
 package     * version    date (UTC) lib source
 bslib       * 0.5.1.9000 2023-10-05 [1] Github (rstudio/bslib@b9ac2cf)
 cachem        1.0.8      2023-05-01 [1] CRAN (R 4.2.3)
 callr         3.7.3      2022-11-02 [1] CRAN (R 4.2.2)
 cli           3.6.1      2023-03-23 [1] CRAN (R 4.2.3)
 crayon        1.5.2      2022-09-29 [1] CRAN (R 4.2.2)
 curl          5.0.2      2023-08-14 [1] CRAN (R 4.2.3)
 desc          1.4.2      2022-09-08 [1] CRAN (R 4.2.2)
 devtools      2.4.5      2022-10-11 [1] CRAN (R 4.2.2)
 digest        0.6.33     2023-07-07 [1] CRAN (R 4.2.0)
 ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.2.0)
 fansi         1.0.4      2023-01-22 [1] CRAN (R 4.2.3)
 fastmap       1.1.1      2023-02-24 [1] CRAN (R 4.2.3)
 fs            1.6.3      2023-07-20 [1] CRAN (R 4.2.0)
 glue          1.6.2      2022-02-24 [1] CRAN (R 4.2.0)
 htmltools     0.5.6      2023-08-10 [1] CRAN (R 4.2.3)
 htmlwidgets   1.6.2      2023-03-17 [1] CRAN (R 4.2.3)
 httpuv        1.6.11     2023-05-11 [1] CRAN (R 4.2.3)
 jquerylib     0.1.4      2021-04-26 [1] CRAN (R 4.2.0)
 jsonlite      1.8.7      2023-06-29 [1] CRAN (R 4.2.0)
 later         1.3.1      2023-05-02 [1] CRAN (R 4.2.3)
 lifecycle     1.0.3      2022-10-07 [1] CRAN (R 4.2.2)
 magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.2.0)
 memoise       2.0.1      2021-11-26 [1] CRAN (R 4.2.0)
 mime          0.12       2021-09-28 [1] CRAN (R 4.2.0)
 miniUI        0.1.1.1    2018-05-18 [1] CRAN (R 4.2.1)
 pillar        1.9.0      2023-03-22 [1] CRAN (R 4.2.3)
 pkgbuild      1.4.2      2023-06-26 [1] CRAN (R 4.2.0)
 pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.2.0)
 pkgload       1.3.2.1    2023-07-08 [1] CRAN (R 4.2.3)
 prettyunits   1.1.1      2020-01-24 [1] CRAN (R 4.2.0)
 processx      3.8.2      2023-06-30 [1] CRAN (R 4.2.0)
 profvis       0.3.8      2023-05-02 [1] CRAN (R 4.2.3)
 promises      1.2.1      2023-08-10 [1] CRAN (R 4.2.3)
 ps            1.7.5      2023-04-18 [1] CRAN (R 4.2.3)
 purrr         1.0.2      2023-08-10 [1] CRAN (R 4.2.3)
 R6            2.5.1      2021-08-19 [1] CRAN (R 4.2.0)
 Rcpp          1.0.11     2023-07-06 [1] CRAN (R 4.2.0)
 remotes       2.4.2.1    2023-07-18 [1] CRAN (R 4.2.3)
 rlang         1.1.1      2023-04-28 [1] CRAN (R 4.2.3)
 rprojroot     2.0.3      2022-04-02 [1] CRAN (R 4.2.0)
 rstudioapi    0.15.0     2023-07-07 [1] CRAN (R 4.2.0)
 sass          0.4.7      2023-07-15 [1] CRAN (R 4.2.3)
 sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.2.0)
 shiny       * 1.7.5      2023-08-12 [1] CRAN (R 4.2.3)
 stringi       1.7.12     2023-01-11 [1] CRAN (R 4.2.2)
 stringr       1.5.0      2022-12-02 [1] CRAN (R 4.2.3)
 tibble        3.2.1      2023-03-20 [1] CRAN (R 4.2.3)
 urlchecker    1.0.1      2021-11-30 [1] CRAN (R 4.2.2)
 usethis       2.2.2      2023-07-06 [1] CRAN (R 4.2.0)
 utf8          1.2.3      2023-01-31 [1] CRAN (R 4.2.3)
 vctrs         0.6.3      2023-06-14 [1] CRAN (R 4.2.3)
 xtable        1.8-4      2019-04-21 [1] CRAN (R 4.2.0)

───────────────────────────────────────────────────────────────

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 by reproducing the supplied nested bslib::accordion() and accordion_panel() example, then inspect the accordion entry points and their Bootstrap behavior. Verify how nested panels interpret multiple=FALSE and multiple=TRUE. Done means inner accordions enforce their own multiple setting without unexpectedly closing the parent panel.

Written by the indexing model from the issue text.

Assessment

Tech stack
bootstrap, r
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.