Skip to content

Commit c572df9

Browse files
committed
Merge branch 'main' into feat/shinychat-dependency
2 parents 84c8bf1 + 0b9188b commit c572df9

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4545

4646
### Bug fixes
4747

48+
* Fixed numerous issues related to programmatically updating selectize options. (#2053)
49+
* `update_selectize(options=...)` no longer gets ignored when `server=False` (the default).
50+
* `update_selectize(options=...)` now works as expected in a module.
51+
4852
* Fixed an issue with `update_selectize()` to properly display labels with HTML reserved characters like "&" (#1330)
4953

5054
* Fixed an issue with `ui.Chat()` sometimes wanting to scroll a parent element. (#1996)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from shiny import App, Inputs, Outputs, Session, module, reactive, ui
2+
3+
4+
@module.ui
5+
def reprex_selectize_ui(label: str):
6+
return ui.input_selectize("x", label, choices=[], multiple=True)
7+
8+
9+
@module.server
10+
def reprex_selectize_server(
11+
input: Inputs, output: Outputs, session: Session, server: bool = True
12+
):
13+
@reactive.effect
14+
def _():
15+
ui.update_selectize(
16+
"x",
17+
choices=[f"Foo {i}" for i in range(3)],
18+
server=server,
19+
options={"placeholder": "Search"},
20+
)
21+
22+
23+
app_ui = ui.page_fluid(
24+
reprex_selectize_ui("serverside", "Server"),
25+
reprex_selectize_ui("clientside", "Client"),
26+
)
27+
28+
29+
def server(input: Inputs, output: Outputs, session: Session):
30+
reprex_selectize_server("serverside", server=True)
31+
reprex_selectize_server("clientside", server=False)
32+
33+
34+
app = App(app_ui, server, debug=True)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# import pytest
2+
from playwright.sync_api import Page, expect
3+
4+
from shiny.playwright import controller
5+
from shiny.run import ShinyAppProc
6+
7+
8+
def test_selectize(page: Page, local_app: ShinyAppProc) -> None:
9+
page.goto(local_app.url)
10+
11+
expect(page.get_by_placeholder("Search")).to_have_count(2)
12+
13+
selectize_menu = controller.InputSelectize(page, "serverside-x")
14+
selectize_menu.expect_choices(["Foo 0", "Foo 1", "Foo 2"])
15+
selectize_menu.expect_multiple(True)
16+
selectize_menu.set(["Foo 0", "Foo 1"])
17+
selectize_menu.expect_selected(["Foo 0", "Foo 1"])
18+
19+
selectize_menu2 = controller.InputSelectize(page, "clientside-x")
20+
selectize_menu2.expect_choices(["Foo 0", "Foo 1", "Foo 2"])
21+
selectize_menu2.expect_multiple(True)
22+
selectize_menu2.set(["Foo 0", "Foo 1"])
23+
selectize_menu2.expect_selected(["Foo 0", "Foo 1"])

0 commit comments

Comments
 (0)