When utilizing conditional panels to dynamically build up my Shiny app, I've noticed that the condition the panel is based on is not initially evaluated. The panel remains visible by default and only becomes hidden after certain actions are taken. This results in the panel being visible even when the condition (input.select1.length = 0) is not met.
For a minimal working example:
Server.R:
shinyServer(function(input, output,session){
output$selectInput1 <- renderUI({
selectInput(
inputId = "select1",
label = "Select",
choices = c('1','2','3'),
selected = NULL,
multiple = TRUE
)
})
})
UI.R:
dashboardPage(
title = "",
## Header content + dropdownMenu
dashboardHeader(
title = tags$b(""),
titleWidth = 250
),
## Sidebar content
dashboardSidebar(
width = 250,
sidebarMenu(
id = "tabs",
menuItem("tab1", tabName = "tab", icon = icon("table"))
)
),
## Body content
dashboardBody(
tabItems(
tabItem(tabName = "tab",
div(
div(
style="float: left; padding-left: 20px; padding-right: 20px; width: 350px; background-color: #F4F4F4; height: calc(100vh - 50px) !important;",
uiOutput('selectInput1')
),
div(
conditionalPanel(
condition = "input.select1.length > 1",
p('hi')
)
)
)
)
)
)
)