Skip to content

Commit a720e43

Browse files
committed
Move to a JSON-only approach
1 parent e44924c commit a720e43

File tree

8 files changed

+46
-69
lines changed

8 files changed

+46
-69
lines changed

shiny/ui/_input_select.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ def _input_select_impl(
273273
if remove_button is None:
274274
remove_button = multiple
275275

276+
# Add our own special remove_button option
277+
options["shinyRemoveButton"] = str(remove_button).lower()
278+
276279
selectize_config = None
277280
if selectize:
278281
selectize_config = tags.script(
@@ -282,8 +285,6 @@ def _input_select_impl(
282285
data_for=resolved_id,
283286
# Which option values should be interpreted as JS?
284287
data_eval=json.dumps(extract_js_keys(options)),
285-
# Can be "both", "true", or "false"
286-
data_remove_button=str(remove_button).lower(),
287288
)
288289

289290
return div(
@@ -313,29 +314,6 @@ def _normalize_choices(x: SelectChoicesArg) -> _SelectChoices:
313314
return x
314315

315316

316-
# Translate remove_button into default selectize plugins
317-
# N.B. remove_button is primarily for multiple=True and clear_button is for
318-
# multiple=False, but both can also be useful in the multiple=True case (i.e., clear
319-
# _all_ selected items)
320-
def _get_default_plugins(
321-
remove_button: Optional[Literal[True, False, "both"]],
322-
multiple: bool,
323-
) -> Optional[str]:
324-
if remove_button is None:
325-
remove_button = multiple
326-
327-
if remove_button is False:
328-
return None
329-
330-
if remove_button is True:
331-
return json.dumps(["remove_button" if multiple else "clear_button"])
332-
333-
if remove_button == "both":
334-
return json.dumps(["remove_button", "clear_button"])
335-
336-
raise ValueError(f"Invalid value for `remove_button`: {remove_button}")
337-
338-
339317
def _render_choices(
340318
x: _SelectChoices, selected: Optional[str | list[str]] = None
341319
) -> TagList:

shiny/ui/_input_update.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@
3838
from ..types import ActionButtonValue
3939
from ._input_check_radio import ChoicesArg, _generate_options
4040
from ._input_date import _as_date_attr
41-
from ._input_select import (
42-
SelectChoicesArg,
43-
_normalize_choices,
44-
_render_choices,
45-
_get_default_plugins,
46-
)
41+
from ._input_select import SelectChoicesArg, _normalize_choices, _render_choices
4742
from ._input_slider import SliderStepArg, SliderValueArg, _as_numeric, _slider_type
4843
from ._utils import JSEval, _session_on_flush_send_msg, extract_js_keys
4944

@@ -771,14 +766,16 @@ def update_selectize(
771766

772767
session = require_active_session(session)
773768

774-
if options is not None or remove_button is not None:
769+
if remove_button is not None:
775770
options = options or {}
771+
options["shinyRemoveButton"] = str(remove_button).lower()
772+
773+
if options is not None:
776774
cfg = tags.script(
777775
json.dumps(options),
778776
type="application/json",
779777
data_for=resolve_id(id),
780778
data_eval=json.dumps(extract_js_keys(options)),
781-
data_remove_button=None if remove_button is None else str(remove_button),
782779
)
783780
session.send_input_message(id, {"config": cfg.get_html_string()})
784781

shiny/www/shared/_version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"note!": "Generated by scripts/htmlDependencies.R: do not edit by hand",
33
"package": "shiny",
4-
"version": "1.11.1.9000 (rstudio/shiny@5f31f11fa7050125c0bef2cb693cf87142e1ee96)"
4+
"version": "1.11.1.9000 (rstudio/shiny@a06da9871b27c9c1d2ca5f8b8c0c0f57c972ed2a)"
55
}

shiny/www/shared/bootstrap/_version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"note!": "Generated by scripts/htmlDependencies.R: do not edit by hand",
3-
"shiny_version": "1.11.1.9000 (rstudio/shiny@5f31f11fa7050125c0bef2cb693cf87142e1ee96)",
3+
"shiny_version": "1.11.1.9000 (rstudio/shiny@a06da9871b27c9c1d2ca5f8b8c0c0f57c972ed2a)",
44
"bslib_version": "0.9.0.9000 (rstudio/bslib@9562108e40a0bffb4a7c8709c2963509435c5c0f)",
55
"htmltools_version": "0.5.8.9000 (rstudio/htmltools@487aa0bed7313d7597b6edd5810e53cab0061198)",
66
"bootstrap_version": "5.3.1"

shiny/www/shared/shiny.js

Lines changed: 17 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/shared/shiny.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/shared/shiny.min.js

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/shared/shiny.min.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)