-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
Hi! A quick question about how updating works for menu_item
when also using shiny.router
. My apologies if I am missing something simple. Here is a repex of a "working" dashboard:
library(shiny)
library(shiny.semantic)
library(shiny.router)
dashboard_page <- div(
titlePanel("Dashboard"),
p("This is a dashboard page")
)
profile_page <- div(
titlePanel("Profile"),
p("This is a profile page")
)
dashboard_callback <- function(input, output, session) {}
profile_callback <- function(input, output, session) {}
router <- make_router(
route("/", dashboard_page, dashboard_callback),
route("profile", profile_page, profile_callback)
)
ui <- semanticPage(
menu(menu_item("Logo"),
menu_item("Dashboard", href = route_link("/"), item_feature = "active item"),
menu_item("Profile", href = route_link("profile")),
class = "secondary pointing menu"
),
router$ui
)
server <- function(input, output, session) {
router$server(input, output, session)
}
shinyApp(ui, server)
It is clear that the routing is working as intended, showing the two pages when selected in the menu. However, the item feature of the selected menu_item
is not updated when clicked, i.e. the "Dashboard" page is always the active menu item. I would think that the render_menu_link
in menu.R
should take care of this, but apparently it does not.
render_menu_link <- function(location, title, active_location = "", icon = NULL) {
class <- if (active_location == location) "active item" else "item"
if (is.null(icon))
icon_ui <- ""
else
icon_ui <- icon(icon)
shiny::tags$a(class = class, href = location, icon_ui, title)
}
Maybe active_location
is not matching location
when using shiny.router
? All help is much appreciated and thanks for a great package! :-)
Metadata
Metadata
Assignees
Labels
No labels