I am trying to set up a brilliant app using shinydashboard, and for the most part, having luck. Nevertheless, I am faced with a quirk with the behavior of the side panels, which, it seems to me, can be avoided, but have not yet been found.
Below is a small example that reproduces the problem I am facing. Basically, there are two sidebarMenus - Menu One and Menu Two, each with two menuSubItems. Switching sub-items to a menu item works fine. So, if I wanted to switch from subItemOne to subItemTwo, no problem. I can do it all day.
I can also switch to subItems in different menus, so switching from subItemOne to subItemThree is fine. The problem is trying to go back. If subItemOne is selected and I try to go to subItemThree and return to subItemOne, I cannot do this. I need to go to subItemTwo, then I can open SubItemOne.
Is there a way to fix this setting so that I can go directly from subItemOne to subItemThree (or two and four) and vice versa?
library('shiny') library('shinydashboard') # Sidebar ############################# sidebar <- dashboardSidebar( width = 290, sidebarMenu( menuItem('Menu One', tabName = 'menuOne', icon = icon('line-chart'), collapsible = menuSubItem('Sub-Item One', tabName = 'subItemOne'), menuSubItem('Sub-Item Two', tabName = 'subItemTwo') ) ), sidebarMenu( menuItem('Menu Two', tabName = 'menuTwo', icon = icon('users'), collapsible = menuSubItem('Sub-Item Three', tabName = 'subItemThree'), menuSubItem('Sub-Item Four', tabName = 'subItemFour') ) ) ) # Body ############################# body <- dashboardBody( tabItems( tabItem(tabName = 'subItemOne', h2('Selected Sub-Item One') ), tabItem(tabName = 'subItemTwo', h2('Selected Sub-Item Two') ), tabItem(tabName = 'subItemThree', h2('Selected Sub-Item Three') ), tabItem(tabName = 'subItemFour', h2('Selected Sub-Item Four') ) ) ) # UI ############################# ui <- dashboardPage( dashboardHeader(title = 'Test', titleWidth = 290), sidebar, body ) # Server ############################# server <- function(input, output){ } shinyApp(ui, server)