-
Notifications
You must be signed in to change notification settings - Fork 137
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I have also described it in the bs4Dash github:
So I love to use bs4Dash but things go wrong if i want to add header menu's as explained here:
https://bs4dash.rinterface.com/reference/navbar-menu
This code works perfectly, but not with golem.
Somehow I get the word 'navmenu' and 'left' added to the header plus dots in the left corner.
library(golem)
create_golem("Test")
golem::add_module(name = "tabs")
# R/mod_tabs.R
mod_tabs_ui <- function(id) {
ns <- NS(id)
tabItems(.list = lapply(1:7, function(i) {
tabItem(tabName = sprintf("Tab%s", i), sprintf("Tab %s", i))
}))
}
mod_tabs_server <- function(id) {
moduleServer(id, function(input, output, session) {
# No specific server logic for tabs in this case
})
}
# R/app_ui.R
app_ui <- function(request) {
tagList(
golem_add_external_resources(),
dashboardPage(
header = dashboardHeader(
navbarMenu(
id = "navmenu",
navbarTab(tabName = "Tab1", text = "Tab 1"),
navbarTab(tabName = "Tab2", text = "Tab 2"),
navbarTab(
text = "Menu",
dropdownHeader("Dropdown header"),
navbarTab(tabName = "Tab3", text = "Tab 3"),
dropdownDivider(),
navbarTab(
text = "Sub menu",
dropdownHeader("Another header"),
navbarTab(tabName = "Tab4", text = "Tab 4"),
dropdownHeader("Yet another header"),
navbarTab(tabName = "Tab5", text = "Tab 5"),
navbarTab(
text = "Sub sub menu",
navbarTab(tabName = "Tab6", text = "Tab 6"),
navbarTab(tabName = "Tab7", text = "Tab 7")
)
)
)
)
),
body = dashboardBody(mod_tabs_ui("tabs")), # Use module here
controlbar = dashboardControlbar(
sliderInput(
inputId = "controller",
label = "Update the first tabset",
min = 1,
max = 4,
value = 1
)
),
sidebar = dashboardSidebar(disable = TRUE)
)
)
}
# R/app_server.R
app_server <- function(input, output, session) {
mod_tabs_server("tabs") # Initialize module
observeEvent(input$controller, {
updateNavbarTabs(
session,
inputId = "navmenu",
selected = paste0("Tab", input$controller)
)
},
ignoreInit = TRUE
)
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
