@raytong, thanks for pointing that out and thanks for the quick response! That was a mistake when oversimplifying my example. Adding the addModule does make that work. My example is actually slightly more complex, I'm trying to render inputs based on the input tab, which works just fine in the main UI but not in the module. Again I hope it's something simple I'm overlooking. I created a slightly more complicated example to show my exact issue.
The filters should pop up when you go to the detail tab, you will see only the filters from the main UI appear and not the module. Hopefully just something I'm overlooking. Thanks again in advance for any thoughts and help.
library(shiny)
library(shinydashboard)
condpanelUI <- function(id) {
ns <- NS(id)
tagList(
conditionalPanel(condition = "input.page_tabs == 'detail_tab'",
ns = ns,
"This is the module conditional panel visible on detail tab"),
#conditionalPanel(condition = paste0("input['",ns("checkbox"),"']"),
conditionalPanel(condition = "input.page_tabs == 'detail_tab'",
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 <- dashboardPage(skin = "black",
title = "Dashboard",
dashboardHeader(title="dashboard"),
dashboardSidebar(sidebarMenu(id = "sidebar",
menuItem("Section", tabName = "sectionTab", icon = icon("flask")),
condpanelUI("foo"),
conditionalPanel(condition = "input.page_tabs == 'detail_tab'", "This is the top-level conditional panel visible on detail tab"),
conditionalPanel(condition = "input.page_tabs == 'detail_tab'", htmlOutput("selectInput"))
)),
dashboardBody(
useShinyjs(),
tabItems(
tabItem(tabName = "sectionTab",
tabsetPanel(id = "page_tabs",
tabPanel(
title = "Summary",
value = "summary_tab",
fluidPage(
)),
tabPanel(
title = "Detail",
value = "detail_tab",
fluidPage(
))
))))
)
server <- function(input, output, session) {
output$selectInput <- renderUI({
selectInput(
inputId = "selectInput",
label = "Conditional Input :",
choices = c("A","B","C")
)
})
callModule(condpanel,"foo")
}
shinyApp(ui, server)