-
Notifications
You must be signed in to change notification settings - Fork 114
Open
Milestone
Description
In the app below, choices includes a "" value. This makes it possible for the user to select "nothing". The problem is that, from a usability perspective, it's hard to know how to enter the "nothing" state.
You can try this on shinylive:
- Select a choice from the input.
- Without using the clear button, attempt to clear the current selection.
- The correct actions are:
- Move focus to the selectize input
- Press Backspace to delete the current input
- Do not press Enter, instead Tab or move focus away from the input.
We could instead detect the presence of "" in choices and turn on the "clear_button" plugin by adding it to the options["plugins"] array.
from shiny.express import input, render, ui
ui.input_selectize(
"filter",
"Filter by",
choices={
"": "Select filter",
"first": "First Choice",
"second": "Second Choice",
},
options={
"plugins": ['clear_button']
}
)
@render.text
def txt():
if input.filter():
return f"Data is filtered by your {input.filter()} choice."
else:
return "The data is not filtered."Metadata
Metadata
Assignees
Labels
No labels