-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Milestone
Description
AFAICT, it isn't possible for users to escape the automatic module namespacing for the conditional input. In the example below, input.switch
is intended to refer to a global "switch"
input, but because ui.panel_conditional()
is called within a module it always namespaces the condition expression to the module.
from shiny import App, module, reactive, render, ui
@module.ui
def counter_ui():
return ui.card(
ui.card_header("Conditional Panel"),
ui.panel_conditional("input.switch", ui.card("Test")),
ui.output_ui("dynamic_card")
)
@module.server
def counter_server(input, output, session, global_switch):
@render.ui()
@reactive.event(global_switch)
def dynamic_card():
print(f"Switch: {global_switch()}")
return ui.card("Dynamic Card") if global_switch() else None
app_ui = ui.page_fluid(
ui.input_switch("switch", "Switch", value=False),
counter_ui("counter1"),
)
def server(input, output, session):
counter_server("counter1", global_switch=input.switch)
app = App(app_ui, server)
Reported on Discord
Metadata
Metadata
Assignees
Labels
No labels