Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions shiny/ui/_input_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -259,12 +259,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_)
Expand Down
13 changes: 5 additions & 8 deletions shiny/ui/_input_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ 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.It is not recommended to use
anything other than a string for these labels. A dictionary of dictionaries is
also supported, and in that case, the top-level keys are treated as
``<optgroup>`` labels.
selected
Expand Down Expand Up @@ -742,19 +742,16 @@ def update_selectize(

# Transform choices to a list of dicts (this is the form the client wants)
# [{"label": "Foo", "value": "foo", "optgroup": "foo"}, ...]

flat_choices: list[FlatSelectChoice] = []
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()
]
)
Expand Down
Loading