Hello, I'm hoping this is a simple question. I'm trying to using conditionalPanel in a module to add htmlOutput. There have been quite a few posts about modules and conditionalPanels, and the addition of the ns parameter which I thought should resolve this. Here is the merge request for the fix that was implemented. Using the same example, I'm wondering what I'm doing wrong when trying to conditionally show htmlOutput. I've tried the old way of handling namespace and the new way with ns = ns.
I hope there's something obvious I'm doing wrong or a work around so that this is possible. I've also tried many combinations of using the ns with the id and not, etc. I still cannot get the htmlOutput selectInput to show on the module side click. Thoughts?
Thanks in advance!
library(shiny)
condpanelUI <- function(id) {
ns <- NS(id)
tagList(
checkboxInput(ns("checkbox"), "Make module panel visible"),
conditionalPanel(condition = "input.checkbox",
ns = ns,
"This is the module conditional panel"),
#conditionalPanel(condition = paste0("input['",ns("checkbox"),"']"), #also tried this
conditionalPanel(condition = "input.checkbox",
ns = ns,
htmlOutput(ns("selectInput")))
)
}
condpanel <- function(input, output, session) {
output$selectInput <- renderUI({
ns <- session$ns
selectInput(
inputId = ns("selectInput"),
label = "Conditional Input :",
choices = c("A","B","C")
)
})
}
ui <- fluidPage(
condpanelUI("foo"),
checkboxInput("checkbox", "Make top-level panel visible"),
conditionalPanel(condition = "input.checkbox", "This is the top-level conditional panel"),
conditionalPanel(condition = "input.checkbox", htmlOutput("selectInput"))
)
server <- function(input, output, session) {
output$selectInput <- renderUI({
selectInput(
inputId = "selectInput",
label = "Conditional Input :",
choices = c("A","B","C")
)
})
}
shinyApp(ui, server)