Skip to content

Commit 9ef4067

Browse files
committed
Updating
1 parent 0ccf0e8 commit 9ef4067

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

shiny/ui/_input_update.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,6 @@ def update_selectize(
722722

723723
session = require_active_session(session)
724724

725-
if not server:
726-
return update_select(
727-
id, label=label, choices=choices, selected=selected, session=session
728-
)
729-
730725
if options is not None:
731726
cfg = tags.script(
732727
json.dumps(options),
@@ -736,6 +731,11 @@ def update_selectize(
736731
)
737732
session.send_input_message(id, {"config": cfg.get_html_string()})
738733

734+
if not server:
735+
return update_select(
736+
id, label=label, choices=choices, selected=selected, session=session
737+
)
738+
739739
# Transform choices to a list of dicts (this is the form the client wants)
740740
# [{"label": "Foo", "value": "foo", "optgroup": "foo"}, ...]
741741
flat_choices: list[FlatSelectChoice] = []

tests/playwright/shiny/components/selectize/app.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,31 @@
33

44
@module.ui
55
def reprex_selectize_ui():
6-
return ui.input_selectize("x", "Server side selectize", choices=[], multiple=True)
6+
return ui.input_selectize("x", "Selectize", choices=[], multiple=True)
77

88

99
@module.server
1010
def reprex_selectize_server(
11-
input: Inputs, output: Outputs, session: Session, starting_value: int = 0
11+
input: Inputs, output: Outputs, session: Session, server: bool = True
1212
):
1313
@reactive.effect
1414
def _():
1515
ui.update_selectize(
1616
"x",
1717
choices=[f"Foo {i}" for i in range(3)],
18-
server=False,
18+
server=server,
1919
options={"placeholder": "Search"},
2020
)
2121

2222

23-
app_ui = ui.page_fluid(reprex_selectize_ui("reprex_selectize"))
23+
app_ui = ui.page_fluid(
24+
reprex_selectize_ui("serverside"), reprex_selectize_ui("clientside")
25+
)
2426

2527

2628
def server(input: Inputs, output: Outputs, session: Session):
27-
reprex_selectize_server("reprex_selectize")
29+
reprex_selectize_server("serverside", server=True)
30+
reprex_selectize_server("clientside", server=False)
2831

2932

3033
app = App(app_ui, server, debug=True)

tests/playwright/shiny/components/selectize/test_selectize.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88
def test_selectize(page: Page, local_app: ShinyAppProc) -> None:
99
page.goto(local_app.url)
1010

11-
selectize_menu = controller.InputSelectize(page, "reprex_selectize-x")
11+
selectize_menu = controller.InputSelectize(page, "serverside-x")
1212
selectize_menu.expect_choices(["Foo 0", "Foo 1", "Foo 2"])
1313
selectize_menu.expect_multiple(True)
1414
selectize_menu.set(["Foo 0", "Foo 1"])
1515
selectize_menu.expect_selected(["Foo 0", "Foo 1"])
16+
17+
selectize_menu2 = controller.InputSelectize(page, "clientside-x")
18+
selectize_menu2.expect_choices(["Foo 0", "Foo 1", "Foo 2"])
19+
selectize_menu2.expect_multiple(True)
20+
selectize_menu2.set(["Foo 0", "Foo 1"])
21+
selectize_menu2.expect_selected(["Foo 0", "Foo 1"])

0 commit comments

Comments
 (0)