The problem here is that childfull menuItems by default don't link to a tabItem - they are used only to present their children after being expanded:
“Childfull” menuItem() s cannot have a tabName or a selected argument (or rather, they can, but this will be completely ignored by Shiny).
Source: Shiny Dashboard Behavior
Childfull means having child tags like your fileInput, the actionButton or another menuItem / menuSubItem.
Please see my answer here:
for a workaround.
Here is a working version of your code:
# Upload library ----
library(shiny)
library(shinyjs)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Simple tabs"),
dashboardSidebar(
useShinyjs(),
sidebarMenu(
id = "tabs",
menuItem("About", tabName = "first",icon = icon("home")),
menuItem("Upload Data", expandedName = "second", icon = icon("home"),
fileInput("file1", "Upload a .txt file ",
accept = c("text/csv", "text/comma-separated-values,text/plain",".csv",
options(shiny.maxRequestSize=900*1024^2))),
actionButton('subm', 'Submit')),
hidden(menuItem("childlessSecond", tabName = "childlessSecond"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "first",
h3("App Ver 0.1.0")
),
tabItem(tabName = "childlessSecond",
h2("Results Table"),
tableOutput("contents")
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$subm, {
output$contents <- renderTable(rownames = TRUE,{
if (is.null(input$file1)) return(NULL)
head(read.csv(input$file1$datapath))
})
updateTabItems(session, "tabs", selected = "childlessSecond" )
})
}
shinyApp(ui, server)