highlight active menuItem in the sidebar of shinydashboard

Hello R users,

I have a lot of hidden menuItems when I launch my shiny App.
Some of them are going to be shown when some buttons are clicked and some other conditions met.

Everything ran as expected but I would like that the active menuItem is highlighted on the sidebar. This is the case with the home page that is never hidden but with all the hidden (from shinyjs package) menuItems, once I show them, the menuItem is not highlighted when it is active.

Anyone has a relatively easy solution for that?

Example of what the sidebar codes can look like:

in the UI for the sidebar:

sidebarMenu(
id = "tabs",
shinyjs::useShinyjs(),
menuItem("Product Selection", tabName = "product_selection", icon = icon("dashboard")),
shinyjs::hidden(div(id="Test",menuItem("Test",tabName = "Test", icon = icon("chart-line")))),
)

in the server for the sidebar action:

observeEvent(input$look, {
ID = someID
shinyjs::show(id= ID,anim = TRUE)
updateTabItems(session, "tabs", ID)
})

Have a nice day,

Maxime

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.