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

nav_select for inserted panels #986

Open
tai-mi opened this issue Feb 19, 2024 · 0 comments
Open

nav_select for inserted panels #986

tai-mi opened this issue Feb 19, 2024 · 0 comments

Comments

@tai-mi
Copy link

tai-mi commented Feb 19, 2024

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.utf8

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

other 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

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

No branches or pull requests

1 participant