Shiny Dashboard: Menu Item: homepage + drop down menu

My question is regards to menuItem and menuSubItem.

As of now, clicking the MenuItem opens a drop down menu, revealing its respective SubMenuItem. Then, clicking the SubMenuItem enables you to access its contents.

I am curious if it’s possible to simultaneously click a MenuItem and:

  1. Open its drop down, revealing the various SubMenuItem (this is the case now)

  2. And additionally, direct to its specific contents.

In effect, I would like each of my MenuItem to have a kind of "Homepage", where you are immediately directed to once you click it (along with the normal presence of a drop menu).

For me, this “Homepage” feature only exists with MenuItems that do not have SubMenuItem. As soon as SubMenuItem are added, clicking the MenuItem only results in a drop down menu.

Below is some example code. I would like to be able to access "Homepages" for both MenuItems (1 and 2) and as well access the drop menu for MenuItem 2. As of now, clicking MenuItem 2 does not bring me to its homepage:

library(shiny)
library(shinydashboard)

# Define UI for application
ui <- dashboardPage(
  dashboardHeader(title = "Shiny Dashboard"),
  
  dashboardSidebar(
    sidebarMenu(
      menuItem("Menu Item 1", tabName = "menu_1"),
      menuItem("Menu Item 2", tabName = "menu_2",
               menuSubItem("Sub Menu Item 1", tabName = "sub_1"), 
               menuSubItem("Sub Menu Item 2", tabName = "sub_2")
               )
      )
    ),
  
  dashboardBody(
    tabItems(
      tabItem(tabName = "menu_1", 
              fluidRow(
                h1("Homepage 1")
                )
              ),
      tabItem(tabName = "menu_2", 
              fluidRow(
                h1("Homepage 2")
                )
              ),
      tabItem(tabName = "sub_1", 
              fluidRow(
                h1("Sub Menu Page 1")
                )
              ), 
      tabItem(tabName = "sub_2", 
              fluidRow(
               h1("Sub Menu Page 2")
               )
              )
      )
    )
  )

# Define server logic
server <- function(input, output) {

  }

# Run the application 
shinyApp(ui = ui, server = server)

Any help with this issue is greatly appreciated.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Hi!, i was looking for this question Shiny Dashboard: Menu Item: homepage + drop down menu but i can't see the answer, please help!

Check out the posts on stackoverflow