Skip to content

Commit 621fbaf

Browse files
fix: Remove HTML Label Option (#2049)
Co-authored-by: Carson Sievert <[email protected]>
1 parent 24b02cf commit 621fbaf

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

CHANGELOG.md

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

2828
### Improvements
2929

30+
* Restricted the allowable types of the `choices` parameter of `input_select()`, `input_selectize()`, `update_select()`, and `update_selectize()` to actual set of allowable types (previously, the type was suggesting HTML-like values were supported). (#2048)
31+
3032
* Improved the styling and readability of markdown tables rendered by `ui.Chat()` and `ui.MarkdownStream()`. (#1973)
3133

3234
* `selectize`, `remove_button`, and `options` parameters of `ui.input_select()` have been deprecated; use `ui.input_selectize()` instead. (Thanks, @ErdaradunGaztea!) (#1947)
@@ -39,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3941

4042
### Bug fixes
4143

44+
* Fixed an issue with `update_selectize()` to properly display labels with HTML reserved characters like "&" (#1330)
45+
4246
* Fixed an issue with `ui.Chat()` sometimes wanting to scroll a parent element. (#1996)
4347

4448
* Explicitly call out module usage in UI input bookmark button documentation. (#1983)

shiny/ui/_input_select.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ._html_deps_external import selectize_deps
2222
from ._utils import JSEval, extract_js_keys, shiny_input_label
2323

24-
_Choices = Mapping[str, TagChild]
24+
_Choices = Mapping[str, str]
2525
_OptGrpChoices = Mapping[str, _Choices]
2626

2727
# Canonical format for representing select options.
@@ -75,8 +75,7 @@ def input_selectize(
7575
choices
7676
Either a list of choices or a dictionary mapping choice values to labels. Note
7777
that if a dictionary is provided, the keys are used as the (input) values and
78-
the values are labels displayed to the user. It is not recommended to use
79-
anything other than a string for these labels. A dictionary of dictionaries is
78+
the values are labels displayed to the user. A dictionary of dictionaries is
8079
also supported, and in that case, the top-level keys are treated as
8180
``<optgroup>`` labels.
8281
selected
@@ -157,8 +156,7 @@ def input_select(
157156
choices
158157
Either a list of choices or a dictionary mapping choice values to labels. Note
159158
that if a dictionary is provided, the keys are used as the (input) values and
160-
the values are labels displayed to the user. It is not recommended to use
161-
anything other than a string for these labels. A dictionary of dictionaries is
159+
the values are labels displayed to the user. A dictionary of dictionaries is
162160
also supported, and in that case, the top-level keys are treated as
163161
``<optgroup>`` labels.
164162
selected
@@ -259,12 +257,6 @@ def _input_select_impl(
259257

260258
choices_ = _normalize_choices(choices)
261259

262-
if _contains_html(choices_):
263-
warn_deprecated(
264-
"Passing anything other than a string to `choices` parameter of "
265-
"`input_select()` and `input_selectize()` is deprecated."
266-
)
267-
268260
selected = restore_input(resolved_id, selected)
269261
if selected is None and not multiple:
270262
selected = _find_first_option(choices_)

shiny/ui/_input_update.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,7 @@ def update_select(
628628
An input label.
629629
choices
630630
Either a list of choices or a dictionary mapping choice values to labels. Note
631-
that if a dictionary is provided, the keys are used as the (input) values so
632-
that the dictionary values can hold HTML labels. A dictionary of dictionaries is
631+
that if a dictionary is provided, the keys are used as the (input) values. A dictionary of dictionaries is
633632
also supported, and in that case, the top-level keys are treated as
634633
``<optgroup>`` labels.
635634
selected
@@ -697,8 +696,7 @@ def update_selectize(
697696
An input label.
698697
choices
699698
Either a list of choices or a dictionary mapping choice values to labels. Note
700-
that if a dictionary is provided, the keys are used as the (input) values so
701-
that the dictionary values can hold HTML labels. A dictionary of dictionaries is
699+
that if a dictionary is provided, the keys are used as the (input) values. A dictionary of dictionaries is
702700
also supported, and in that case, the top-level keys are treated as
703701
``<optgroup>`` labels.
704702
selected
@@ -746,15 +744,11 @@ def update_selectize(
746744
if choices is not None:
747745
for k, v in _normalize_choices(choices).items():
748746
if not isinstance(v, Mapping):
749-
flat_choices.append(
750-
FlatSelectChoice(value=k, label=session._process_ui(v)["html"])
751-
)
747+
flat_choices.append(FlatSelectChoice(value=k, label=v))
752748
else: # The optgroup case
753749
flat_choices.extend(
754750
[
755-
FlatSelectChoice(
756-
optgroup=k, value=k2, label=session._process_ui(v2)["html"]
757-
)
751+
FlatSelectChoice(optgroup=k, value=k2, label=v2)
758752
for (k2, v2) in v.items()
759753
]
760754
)

0 commit comments

Comments
 (0)