diff --git a/CHANGELOG.md b/CHANGELOG.md index ab2aa6f47..ee42b9ed3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements +* 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) + * Improved the styling and readability of markdown tables rendered by `ui.Chat()` and `ui.MarkdownStream()`. (#1973) * `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 ### Bug fixes +* Fixed an issue with `update_selectize()` to properly display labels with HTML reserved characters like "&" (#1330) + * Fixed an issue with `ui.Chat()` sometimes wanting to scroll a parent element. (#1996) * Explicitly call out module usage in UI input bookmark button documentation. (#1983) diff --git a/shiny/ui/_input_select.py b/shiny/ui/_input_select.py index 4d144b3ca..5bce83be4 100644 --- a/shiny/ui/_input_select.py +++ b/shiny/ui/_input_select.py @@ -21,7 +21,7 @@ from ._html_deps_external import selectize_deps from ._utils import JSEval, extract_js_keys, shiny_input_label -_Choices = Mapping[str, TagChild] +_Choices = Mapping[str, str] _OptGrpChoices = Mapping[str, _Choices] # Canonical format for representing select options. @@ -75,8 +75,7 @@ def input_selectize( choices Either a list of choices or a dictionary mapping choice values to labels. Note that if a dictionary is provided, the keys are used as the (input) values and - the values are labels displayed to the user. It is not recommended to use - anything other than a string for these labels. A dictionary of dictionaries is + the values are labels displayed to the user. A dictionary of dictionaries is also supported, and in that case, the top-level keys are treated as ```` labels. selected @@ -157,8 +156,7 @@ def input_select( choices Either a list of choices or a dictionary mapping choice values to labels. Note that if a dictionary is provided, the keys are used as the (input) values and - the values are labels displayed to the user. It is not recommended to use - anything other than a string for these labels. A dictionary of dictionaries is + the values are labels displayed to the user. A dictionary of dictionaries is also supported, and in that case, the top-level keys are treated as ```` labels. selected @@ -259,12 +257,6 @@ def _input_select_impl( choices_ = _normalize_choices(choices) - if _contains_html(choices_): - warn_deprecated( - "Passing anything other than a string to `choices` parameter of " - "`input_select()` and `input_selectize()` is deprecated." - ) - selected = restore_input(resolved_id, selected) if selected is None and not multiple: selected = _find_first_option(choices_) diff --git a/shiny/ui/_input_update.py b/shiny/ui/_input_update.py index 80b0255e9..cad0af229 100644 --- a/shiny/ui/_input_update.py +++ b/shiny/ui/_input_update.py @@ -628,8 +628,7 @@ def update_select( An input label. choices Either a list of choices or a dictionary mapping choice values to labels. Note - that if a dictionary is provided, the keys are used as the (input) values so - that the dictionary values can hold HTML labels. A dictionary of dictionaries is + that if a dictionary is provided, the keys are used as the (input) values. A dictionary of dictionaries is also supported, and in that case, the top-level keys are treated as ```` labels. selected @@ -697,8 +696,7 @@ def update_selectize( An input label. choices Either a list of choices or a dictionary mapping choice values to labels. Note - that if a dictionary is provided, the keys are used as the (input) values so - that the dictionary values can hold HTML labels. A dictionary of dictionaries is + that if a dictionary is provided, the keys are used as the (input) values. A dictionary of dictionaries is also supported, and in that case, the top-level keys are treated as ```` labels. selected @@ -746,15 +744,11 @@ def update_selectize( if choices is not None: for k, v in _normalize_choices(choices).items(): if not isinstance(v, Mapping): - flat_choices.append( - FlatSelectChoice(value=k, label=session._process_ui(v)["html"]) - ) + flat_choices.append(FlatSelectChoice(value=k, label=v)) else: # The optgroup case flat_choices.extend( [ - FlatSelectChoice( - optgroup=k, value=k2, label=session._process_ui(v2)["html"] - ) + FlatSelectChoice(optgroup=k, value=k2, label=v2) for (k2, v2) in v.items() ] )