-
Notifications
You must be signed in to change notification settings - Fork 114
Open
Labels
Description
I've noticed some unusual behavior in input_checkbox_group():
When I define a reactive effect to update the checkbox choices, the choices are updated in the UI as expected, but the new pre-selected choices are not applied.
Everything works fine if I don't include the reactive effect code. Am I missing something?
Reproducible code:
from shiny import App, ui, reactive
options = {
"opt1": [5, 10, 15, 30, 60],
"opt2": [5, 10, 20]
}
app_ui = ui.page_navbar(
ui.nav_panel(
"π",
ui.layout_sidebar(
ui.sidebar(
ui.input_radio_buttons(
id = "aaa",
label = ui.strong("Label aaa:"),
choices = {"opt1": "Option 1", "opt2": "Option 2"},
selected = "opt1",
width = "100%"
),
ui.input_checkbox_group(
id = "bbb",
label = ui.strong("Label bbb"),
choices = options["opt1"],
selected = options["opt1"],
inline = True,
width = "100%"
)
),
"Content"
)
),
title = ui.strong("Title"),
fillable = True
)
def server(input, output, session):
@reactive.effect
def _():
choice = input.aaa()
ui.update_checkbox_group(
id = "bbb",
choices = options[choice],
selected = options[choice]
)
app = App(app_ui, server)
Shinylive app demo: