I am trying to modulate a complex Shiny application for which I have a conditionalPanel that should only appear under a certain input state.
Before I did everything modular, the input and conditional panel were both in ui.R , so I could reference the input using something like this:
conditionalPanel("input.select == 'Option one'", p('Option one is selected'))
Now that I have modular things, access to input is more complicated. I thought this was a way to do this, but itβs not quite right. (Here I combined things into a single stand-alone script):
library(shiny)
I think this should work, but it doesnβt - it only works if I link to output$selected in the main ui section:
ui <- shinyUI(fluidPage( selectorUI('id1'), textOutput('selected'),
Unfortunately, of course, this has an undesirable effect for rendering the result of textOutput('selected') . I can only guess that the reason for this is that it somehow causes a reactive reaction in such a way that the JavaScript link itself is missing.
Any idea how I get this conditional panel to work correctly?
Thanks..
EDIT: the error actually fails: https://github.com/rstudio/shiny/issues/1318 . See my own answer below.
But also note that I really like the renderUI solution indicated in the accepted answer is better than my original conditionalPanel approach.
source share