I noticed Shiny will not keep the order of items that you set in the selected argument. For my use case this ordering matters. The following code will set the order to "A", "C", "D" instead of "C", "A", "D"
#_input_selectize.py
def _render_choices(
x: _SelectChoices, selected: Optional[str | list[str]] = None
) -> TagList:
result = TagList()
if x is None:
return result
for k, v in x.items():
if isinstance(v, Mapping):
result.append(
tags.optgroup(
*(_render_choices(cast(_SelectChoices, v), selected)), label=k
)
)
else:
is_selected = False
if isinstance(selected, list):
is_selected = k in selected
else:
is_selected = k == selected
result.append(tags.option(v, value=k, selected=is_selected))
return result
Is there a chance this can be fixed?
An additional note; it is strange to me that input.my_selectize() will return a tuple, but the selected will not accept a tuple, only a list.
Hi!
I noticed Shiny will not keep the order of items that you set in the
selected
argument. For my use case this ordering matters. The following code will set the order to "A", "C", "D" instead of "C", "A", "D"Pretty sure the issue lies in:
Is there a chance this can be fixed?
An additional note; it is strange to me that
input.my_selectize()
will return a tuple, but theselected
will not accept a tuple, only a list.