I have a shiny app with tabsetpanels and conditional panels in the sidebar panel. The problem is that one of the conditional panels also appears when it shouldn't. Below is the code: I show the name of the panel in the sidebar panel. If I click "Assumptions and scenarios" and then on "Assumptions" in the sidebar panel I expect to only see "Assumptions" but I also get "Car aggregate". I have studied the code for over two hours, playing around with it, but I can't find the error (or pehaps it is a bug). I would very much appreciate some help. This is the code
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
conditionalPanel(
condition = "input.tabs_a == 't_ass'",
h4("Assumptions")
),
conditionalPanel(
condition = "input.tabs_c == 't_cara'",
h4("Car aggregate")
), # End conditionalPanel
conditionalPanel(
condition = "input.tabs_c == 't_carf'",
h4("Car fuel")
), # End conditionalPanel
conditionalPanel(
condition = "input.tabs_c == 't_carfp'",
h4("Car fuel power:")
) # End conditionalPanel
), # End sidebarPanel
mainPanel(
tabsetPanel(
type = "tabs",
tabPanel(
"Assumptions and Scenarios",
tabsetPanel(
type = "tabs", id = "tabs_a",
tabPanel(
"Assumptions", value = "t_ass"
), # Close tabpanel t_ass,
tabPanel(
"Scenarios", value = "t_scen"
) # Close tabpanel t_scen
) # Close tabsetpanel
), # Close tabPanel t_Ass
tabPanel(
"Transport results",
tabsetPanel(
type = "tabs", id = "tabs_c",
tabPanel(
"Cars: Aggregated", value = "t_cara"
), # Close tabpanel t_cara
tabPanel(
"Cars: Fuel", value = "t_carf"
), # Close tabpanel
tabPanel(
id = "t_carfp",
"Cars: Fuel vs Power", value = "t_carfp",
) # Close tabpanel t_carfp
) # Close tabset tabs_c
) # Close tabpanel Transport results
) # Close tabset tabs_a
) # End mainPanel
) # End sidebarLayout
) # End fluidPage
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
you could try adding additional logical conditions to change the behavioud, in this example I only show the tabs_c related panels when the tabs_a is set to t_scen (and not t_ass)
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
conditionalPanel(
condition = "input.tabs_a == 't_ass'",
h4("Assumptions")
),
conditionalPanel(
condition = "input.tabs_c == 't_cara' && input.tabs_a == 't_scen'",
h4("Car aggregate")
), # End conditionalPanel
conditionalPanel(
condition = "input.tabs_c == 't_carf' && input.tabs_a == 't_scen'",
h4("Car fuel")
), # End conditionalPanel
conditionalPanel(
condition = "input.tabs_c == 't_carfp' && input.tabs_a == 't_scen'",
h4("Car fuel power:")
) # End conditionalPanel
), # End sidebarPanel
mainPanel(
tabsetPanel(
type = "tabs",
tabPanel(
"Assumptions and Scenarios",
tabsetPanel(
type = "tabs", id = "tabs_a",
tabPanel(
"Assumptions", value = "t_ass"
), # Close tabpanel t_ass,
tabPanel(
"Scenarios", value = "t_scen"
) # Close tabpanel t_scen
) # Close tabsetpanel
), # Close tabPanel
tabPanel(
"Transport results",
tabsetPanel(
type = "tabs", id = "tabs_c",
tabPanel(
"Cars: Aggregated", value = "t_cara"
), # Close tabpanel t_cara
tabPanel(
"Cars: Fuel", value = "t_carf"
), # Close tabpanel
tabPanel(
id = "t_carfp",
"Cars: Fuel vs Power", value = "t_carfp",
) # Close tabpanel t_carfp
) # Close tabset tabs_c
) # Close tabpanel Transport results
) # Close tabset tabs_a
) # End mainPanel
) # End sidebarLayout
) # End fluidPage
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)