rstudio / rstudio/bslib

nav_menu remains open after using nav_select

Open
#894 2 comments 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

nav_menu remains open

The nav_menu remains open after using nav_select to update a nav_panel inside a nav_menu. The only way for users to close it is to click on the menu again.

image

library(shiny)
library(bslib)

ui <- page_navbar(
  title = "example",
  id = 'nav',
  nav_panel("a",
    fluidRow(actionButton("btn", "Go to navmenu item"))
  ),
  nav_menu("Menu",
    nav_panel("nested 1"),
    nav_panel("nested 2")
  )
)

server <- function(input, output, session) {
  observeEvent(input$btn, nav_select(id = "nav", selected = "nested 1"))
}

shinyApp(ui, server)
Session Info

─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.2 (2022-10-31 ucrt)
 os       Windows 10 x64 (build 22621)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/Los_Angeles
 date     2023-11-03
 rstudio  2023.06.0+421 Mountain Hydrangea (desktop)
 pandoc   NA

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

Run the provided Shiny example to reproduce the open-menu behavior, then trace the bslib implementation of nav_menu and nav_select. Identify the navigation state change involved and add regression coverage if the existing tests provide a suitable location; done means selecting nested 1 closes the menu without requiring another click.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.