nav_select for inserted panels
Nobody has claimed this yet.
- Dominant language
- SCSS
- Stars
- 569
- Forks
- 72
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 5
Description
Describe the problem
It seems like I am not able to use nav_select to select nav_panel's that I have inserted (only ones that were written into the ui)?
library(shiny)
library(bslib)
ui <- page_navbar(
title='temp', id='page',
nav_panel(title='login', tags$h3('login'), actionButton('login','Login'))
)
server <- function(input, output) {
observe({
nav_insert(id='page', target='login', nav_panel(
title='page 1', value='pg1', fluidPage(
tags$h3('Page 1'),
actionButton('next_button', 'Back (login)'),
actionButton('back_button', 'Next (page 2)'))
))
nav_insert(id='page', target='pg1', nav_panel(
title='page 2', value='pg2', fluidPage(
tags$h3('Page 2'))
))
# nav_remove(id='page', target='login')
}) |> bindEvent(input$login)
observe({
nav_select(id='page', selected='pg2') # this doesn't work
}) |> bindEvent(input$back_button)
observe({
nav_select(id='page', selected='login') # this works
}) |> bindEvent(input$next_button)
}
# Run the application
shinyApp(ui = ui, server = server)
Session Info
R version 4.3.2 (2023-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22631)Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8time zone: America/Los_Angeles
tzcode source: internalattached base packages:
[1] stats graphics grDevices utils datasets methods
[7] baseother attached packages:
[1] bslib_0.6.1.9001 shiny_1.7.5.1
loaded via a namespace (and not attached):
[1] vctrs_0.6.4 cli_3.6.2 rlang_1.1.3
[4] promises_1.2.1 jsonlite_1.8.8 xtable_1.8-4
[7] glue_1.7.0 htmltools_0.5.7 httpuv_1.6.12
[10] sass_0.4.8 rsconnect_1.1.1 fansi_1.0.5
[13] jquerylib_0.1.4 tibble_3.2.1 ellipsis_0.3.2
[16] fastmap_1.1.1 lifecycle_1.0.4 memoise_2.0.1
[19] compiler_4.3.2 fs_1.6.3 pkgconfig_2.0.3
[22] Rcpp_1.0.11 rstudioapi_0.15.0 later_1.3.1
[25] digest_0.6.34 R6_2.5.1 utf8_1.2.4
[28] pillar_1.9.0 magrittr_2.0.3 tools_4.3.2
[31] withr_2.5.2 mime_0.12 cachem_1.0.8
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Shiny example and reproduce the difference between selecting the inserted pg2 panel and the original login panel. Trace the nav_insert and nav_select entry points to determine why the inserted panel is not selected, then verify that selecting pg2 works after insertion without breaking selection of login.
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
- Clearly specified
- Newbie friendliness
- 38/100