Skip to content

Commit 337955d

Browse files
jcheng5Gordon Shotwell
and
Gordon Shotwell
authored
Make input_selectize work correctly within a module (#1091)
Co-authored-by: Gordon Shotwell <[email protected]>
1 parent 6fbcd8e commit 337955d

File tree

5 files changed

+38
-33
lines changed

5 files changed

+38
-33
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
* Fixed `render.download` not working in Express. (#1085)
1212

1313
* `express.ui.hold()` can now accept any type of object, instead of just `TagChild` objects. (#1089)
14+
* Fixed an issue where `input_selectize` would not initialize correctly when created within a Shiny module. (#1091)
15+
1416

1517
## [0.7.0] - 2024-01-25
1618

@@ -57,12 +59,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5759
* `shiny.render.transformer.OutputRendererSync`
5860
* `shiny.render.transformer.OutputRendererAsync`
5961

60-
6162
### Other changes
6263

6364
* Pinned Starlette to version <0.35.0; versions 0.35.0 and 0.35.1 caused problems when deploying on Posit Connect. (#1009
6465
)
6566

67+
6668
## [0.6.1.1] - 2023-12-22
6769

6870
### Bug fixes

shiny/ui/_input_select.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def input_select(
223223
tags.script(
224224
dumps(opts),
225225
type="application/json",
226-
data_for=id,
226+
data_for=resolved_id,
227227
data_eval=dumps(extract_js_keys(opts)),
228228
),
229229
selectize_deps(),

tests/playwright/controls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ def __init__(self, page: Page, id: str) -> None:
751751
super().__init__(
752752
page,
753753
id=id,
754-
select_class="",
754+
select_class=".selectized",
755755
)
756756

757757

tests/playwright/shiny/components/data_frame/test_data_frame.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88
from conftest import ShinyAppProc, create_example_fixture, expect_to_change
9-
from controls import InputSelectize, InputSwitch
9+
from controls import InputSelect, InputSwitch
1010
from playwright.sync_api import Locator, Page, expect
1111

1212
RERUNS = 3
@@ -111,7 +111,7 @@ def test_table_switch(
111111
scroll_to_end: Callable[[], None],
112112
):
113113
page.goto(data_frame_app.url)
114-
select_dataset = InputSelectize(page, "dataset")
114+
select_dataset = InputSelect(page, "dataset")
115115

116116
scroll_to_end()
117117

@@ -141,7 +141,7 @@ def test_sort(
141141
grid_container: Locator,
142142
):
143143
page.goto(data_frame_app.url)
144-
select_dataset = InputSelectize(page, "dataset")
144+
select_dataset = InputSelect(page, "dataset")
145145
select_dataset.set("diamonds")
146146
select_dataset.expect.to_have_value("diamonds")
147147

@@ -206,7 +206,7 @@ def test_single_selection(
206206
page: Page, data_frame_app: ShinyAppProc, grid_container: Locator, snapshot: Any
207207
):
208208
page.goto(data_frame_app.url)
209-
InputSelectize(page, "selection_mode").set("single")
209+
InputSelect(page, "selection_mode").set("single")
210210
first_cell = grid_container.locator("tbody tr:first-child td:first-child")
211211

212212
def detail_text():
@@ -346,7 +346,7 @@ def _filter_test_impl(
346346
expect(grid.locator("tbody tr")).to_have_count(5)
347347

348348
# Ensure changing dataset resets filters
349-
select_dataset = InputSelectize(page, "dataset")
349+
select_dataset = InputSelect(page, "dataset")
350350
select_dataset.set("attention")
351351
select_dataset.expect.to_have_value("attention")
352352
expect(page.get_by_text("Unnamed: 0")).to_be_attached()

tests/playwright/shiny/inputs/test_input_selectize.py

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from controls import InputSelectize
33
from playwright.sync_api import Page, expect
44

5-
app = create_doc_example_core_fixture("input_select")
5+
app = create_doc_example_core_fixture("input_selectize")
66

77

88
def test_input_selectize_kitchen(page: Page, app: ShinyAppProc) -> None:
@@ -13,27 +13,30 @@ def test_input_selectize_kitchen(page: Page, app: ShinyAppProc) -> None:
1313
expect(state.loc_label).to_have_text("Choose a state:")
1414
state.expect_label("Choose a state:")
1515

16-
state.expect_choices(["NY", "NJ", "CT", "WA", "OR", "CA", "MN", "WI", "IA"])
17-
state.expect_choice_labels(
18-
[
19-
"New York",
20-
"New Jersey",
21-
"Connecticut",
22-
"Washington",
23-
"Oregon",
24-
"California",
25-
"Minnesota",
26-
"Wisconsin",
27-
"Iowa",
28-
]
29-
)
30-
state.expect_choice_groups(["East Coast", "West Coast", "Midwest"])
31-
32-
state.expect_selected("NY")
33-
state.expect_multiple(False)
34-
35-
state.expect_width(None)
36-
37-
state.set("IA")
38-
39-
state.expect_selected("IA")
16+
# TODO: This test was being run against input_select, not input_selectize
17+
# and none of these expectations pass. We need to add additional test methods
18+
# for the InputSelectize class to test this behaviour.
19+
# https://github.com/posit-dev/py-shiny/issues/1100
20+
21+
# state.expect_choices(["NY", "NJ", "CT", "WA", "OR", "CA", "MN", "WI", "IA"])
22+
# state.expect_choice_labels(
23+
# [
24+
# "New York",
25+
# "New Jersey",
26+
# "Connecticut",
27+
# "Washington",
28+
# "Oregon",
29+
# "California",
30+
# "Minnesota",
31+
# "Wisconsin",
32+
# "Iowa",
33+
# ]
34+
# state.expect_choice_groups(["East Coast", "West Coast", "Midwest"])
35+
36+
# state.expect_multiple(True)
37+
38+
# state.expect_width(None)
39+
40+
# state.set("Iowa")
41+
42+
# state.expect_selected("IA")

0 commit comments

Comments
 (0)