I would need multiple tabs in my interface, and in each of them I would like to use conditionalPanel. As you will see with the reproducible code here below, the conditionalPanel works in the first tab, but not in the other tabs.
ui <- pageWithSidebar(
headerPanel("Hello !"),
sidebarPanel(
tabsetPanel(
tabPanel("a",
textInput(inputId = "A1", label = "1:", value = "A1"),
checkboxInput(inputId = "new_A2",
label = "Add another one",
value = FALSE),
conditionalPanel(
condition = "input.new_A2 == true",
textInput(inputId = "A2", label = "2:", value = "A2")
)),
tabPanel("b",
textInput(inputId = "B1", label = "1:", value = "C1"),
checkboxInput(inputId = "new_B2",
label = "Add another one",
value = FALSE),
conditionalPanel(
condition = "input.new_B2 == true",
textInput(inputId = "B2", label = "2:", value = "C2")
)
)
)
),
mainPanel()
)
server <- function(input,output){
}
runApp(list(ui=ui,server=server))
I know there are many questions related to conditionalPanel, but I haven't found the answer to this one yet.
Thank you in advance, any suggestion highly appreciated
Give your tabset panel an id for example tabsetPanel(id="tabs"
and add the condition when the tab "b" is focused input.tabs == 'b'
For example in your 2nd conditional panel the condition will be :
condition = "input.tabs == 'b' & input.new_B2 == true"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With