0
votes

Here is the code to a simple Shiny app:

UI

    library(shiny)
    shareholders.list <- c("Investor A", "Investor B")
    tmp.label.select.inv <- "Select one or multiple investors:"
    shinyUI(navbarPage(    
      title = "App",
      titlePanel(title = "TITLE"),
      tabPanel("Tab 1"             
        , sidebarLayout(
            sidebarPanel(
              style = "font-family: 'Segoe UI';
                       color: #FFFFFF;
                       background: #014d92;",
              selectInput("tmp.IDs", 
                label = tmp.label.select.inv,      
                choices = union("All", shareholders.list),
                multiple = T,
                width = 245
               ), 
               actionButton("select.all", 
                 em("Select / Deselect All"),
                 icon = icon("ok-sign", lib = "glyphicon"),
                 width = 245,
                 style="color: #000000; 
                       background: #FFFFFF; 
                       border-color: #000000"
                ),       
                width = 2                
              ),                           
              mainPanel(                
                h5(em("Chosen Investors: "), 
                br(),strong(textOutput("selected_tmp.IDs"))),
                br(),br(),
                tableOutput("table_tmp.IDs")
              ),      
              position = "left"      
            )
          )    
          , tabPanel("Download Tables",
              mainPanel(
                textOutput("odd_even_select.all")
            ))   
            , selected = "Tab 1"
          )
        )

Server

    shinyServer(function(input, output) {

        output$selected_tmp.IDs <- renderText({
          paste0(input$tmp.IDs)
        })

    })

The problem is that the app keeps displaying "tab-pane active tab-5966-1 " on both tabs.

Any idea how to fix it?

Edit:

I have edited the code and added more details in order to be replicable (note that the unwanted display in the above instance now states "tab-25-25-1" - c.f. image below).

enter image description here

1
I can't reproduce any runtime-issues since your example has syntax errors. There is no titlePanel argument in navbarPageGregor de Cillia
titlePanel might not be indicated in the navbarPage documentation, but I can assure you it works.niko
I an error message "Tabs should all be unnamed arguments, but some are named: titlePanel" when I try to run your code as-is. Using shiny-1.0.5Gregor de Cillia
Please try to create a minimal example that starts an app when your code is copy-pasted like, for example, hereGregor de Cillia
@GregordeCillia I had to thin my code as my question had to much coding, that is why I tried to make it as short as possible. I believe however it should work now.niko

1 Answers

0
votes

The issue you have is that you use the output of the function shiny::titlePanel as an argument of navbarPage. Here is a simpler app that basically leads to the same behavior

library(shiny)

shinyApp(
  ui = navbarPage(
    title = "app",
    titlePanel("Title"),
    tabPanel("Tab1", "content1"),
    tabPanel("Tab2", "content2")
  ),
  server = function(input, output){}
)

From the documentation of ?navbarPage, it is clear that all unnamed arguments (...) should be tabPanel elements or strings.

... tabPanel elements to include in the page. The navbarMenu function also accepts strings, which will be used as menu section headers. If the string is a set of dashes like "----" a horizontal separator will be displayed in the menu.

I don't know what you expect to happen when you put a titlePanel here. Do you want the title to show up in every tab or together with the "app" title?

Anyways, removing the titlePanel fixes the problem

shinyApp(
  ui = navbarPage(
    title = "app",
    tabPanel("Tab1", "content1"),
    tabPanel("Tab2", "content2")
  ),
  server = function(input, output){}
)