0

I want to get a fixed Sidebar without any dropdown arrow. Could not find anything related to my issue, in RShiny, This is what I have.

Yet I want tools without any arrow. Here is the initial code:

 app_ui <-
        shiny::fluidPage(
          theme = shinythemes::shinytheme("united"),
          
          tags$head(tags$style(".navbar {margin-bottom: 0px;}")),
          
          tags$head(
            tags$style(".container-fluid {padding-right: 0px; padding-left: 0px;}")
          ),
        
        # Your application UI logic
            navbarPage(
              title = div(
                img(src = "www/bftb_logo_v8_bare.png", height = "30px"),
                "AZ Oncology Bioinformatics Toolbox"
              ),
              windowTitle = "BFTB Landing Page",
            
            # windowTitle = "BFTB Landing Page",
            # title = div(img(src = "www/bftb_logo_v8_bare.png", height = "30px"), "AZ Oncology Bioinformatics Toolbox"),
            # theme = shinythemes::shinytheme("cerulean"),
            tabPanel("Toolbox", icon = icon("wrench"),disable = TRUE,
                     shinydashboard::dashboardPage(
                      header = shinydashboard::dashboardHeader(title = "   ", titleWidth = 300, disable = TRUE),
                       shinydashboard::dashboardSidebar(
                         width = 300 ,
                         shinydashboard::sidebarMenu(
                           shinydashboard::menuItem(
                             "Tools",
                             tabName = "tools_app",
                             icon = icon("wrench"),
                             shinydashboard::menuSubItem(
                               "Gene Expression/Signature/Pathways",
                               tabName = "gene_app",
                               icon = icon("chart-line")
                             ),
                           etc, etc, 

I have tried to add a new line of code in sideBarMenu

 id = 'sidebar',
 style = "position: relative; overflow: visible;",

And inserted in the wider code:

app_ui <- shiny::fluidPage(),
            navbarPage(
              title = div(
                img(src = "www/my.png", height = "30px"),
                "Toolbox"
              ),
              windowTitle = "BFTB Landing Page",
            
            # windowTitle = "BFTB Landing Page",
            # title = div(img(src = "www/bftb_logo_v8_bare.png", height = "30px"), "AZ Oncology Bioinformatics Toolbox"),
            # theme = shinythemes::shinytheme("cerulean"),
            tabPanel("Toolbox", icon = icon("wrench"),disable = TRUE,
                     shinydashboard::dashboardPage(
                      header = shinydashboard::dashboardHeader(title = "   ", titleWidth = 300, disable = TRUE),
                       shinydashboard::dashboardSidebar(
                         width = 300 ,
                         shinydashboard::sidebarMenu(
                           id = 'sidebar',
                           style = "position: relative; overflow: visible;",
                           shinydashboard::menuItem(
                             "Tools",
                             tabName = "tools_app",
                             icon = icon("wrench"),
                             shinydashboard::menuSubItem(
                               "Gene Expression/Signature/Pathways",
                               tabName = "gene_app",
                               icon = icon("chart-line")
                             ),
                      etc. etc, 

And yet get the same arrow down, without fixing it. Now I thought it may be due to the menuSubItem functionality, therefore forces them to behave as subItems and not removing the bar. Thus I have written the code with menuItem and placed all the elements as 'menuItem'

But then I got an error "body is missing" when run again the app. Clearly I have the body inside the code. See pic for reference:

I have my body part of the code , this is an example.

 shinydashboard::dashboardBody(
                     shinydashboard::tabItems(
                       shinydashboard::tabItem("tools_app", mod_tools_path_ui("tools_path_ui_1")),
                       shinydashboard::tabItem("gene_app", mod_gene_expressions_sign_path_ui("gene_expression_sign_path_ui")), 

Thus I need to understand why I cannot get the Tools as fixed, as a heading to the subItems I have in the picture above. How to solve this ?

GaB
  • 1,076
  • 2
  • 16
  • 29
  • 2
    Hi, you should make your example more minimal so that it is easier to reproduce the error and to find its cause. I see several functions that are not useful here: almost all `shinydashboard::menuSubItem()`, `shinytheme()` functions, the `golem` code, etc. – bretauv Mar 15 '23 at 08:38
  • so, I've got rid of golem and commented out codes. But cannot get rid of shinydashboard::menuSubItem since I need to give a bit of context. I also keep shinytheme() for context reason. I have tried so many codes for so many days, so I want to make sure people understand the context of my code as well – GaB Mar 15 '23 at 08:46
  • You don't need to have 4 `menuSubItem`, 1 or 2 should be enough. Similarly, you don't need to use an image in the title bar (especially because we don't have this image anyway), etc.. You may want to keep context because it's easier for you, but it just adds unnecessary noise that makes it harder to find the actual problem. – bretauv Mar 15 '23 at 08:50
  • Finally, even if you reduce the code, this example is not [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example): we should be able to copy-paste your code in R and have the same error but the code for `app_ui` is incomplete and the `app_server` part is missing – bretauv Mar 15 '23 at 08:52
  • Can't you just remove the Tools `menuItem` and promote all the remaining `menuSubItem`s to `menuItem`s? If Tools isn't the header for a dropdown, it appears to have no purpose... – Limey Mar 15 '23 at 09:01
  • when you see "body is missing" and you clearly have a `body` argument in your call, you most likely have a missing (or extra) comma or bracket. Also, nesting `dashboardPage` within `navbarPage` within `fluidPage` seems just .... wrong. – Limey Mar 15 '23 at 09:03
  • so, you see, I get rid of code and now I get other people telling me it is wrong. – GaB Mar 15 '23 at 09:05
  • @GaB I made an answer showing how to transform your original code into a reproducible example. I'll remove it later. – bretauv Mar 15 '23 at 09:44

1 Answers1

0

I have solved the above issue by getting rid of the 'Tools' as a 'menuItem' (see the uncommented part of the code) and treating all the other menuSubItems as menuItems. I wanted to have it as a fixed side bar.

Here is part of the code:

tabPanel("Toolbox", icon = icon("wrench"),disable = TRUE,
                 shinydashboard::dashboardPage(
                   header = shinydashboard::dashboardHeader(title = "   ", titleWidth = 300, disable = TRUE),
                   shinydashboard::dashboardSidebar(
                     tags$style(".left-side, .main-sidebar {padding-top: 50px}"),
                     width = 300 ,
                     shinydashboard::sidebarMenu(
                       # shinydashboard::menuItem(
                       #   "Tools",
                       #   tabName = "tools_app",
                       #   icon = icon("wrench"),
                       shinydashboard::menuItem(
                         "Gene Expression/Signature/Pathways",
                         tabName = "gene_app",
                         icon = icon("chart-line")
                       ),
                       shinydashboard::menuItem(
                         "Genomic",
                         tabName = "genomic_app",
                         icon = icon("universal-access")
                       ),
                       shinydashboard::menuItem(
                         "Epigenetics",
                         tabName = "epi_app",
                         icon = icon("chart-bar")
                       ),
GaB
  • 1,076
  • 2
  • 16
  • 29