Uh oh!
There was an error while loading. Please reload this page.
Fix #2989: dcc.Dropdown options order preserved during search - #3680
Conversation
AnnMarieW
commented
Mar 25, 2026
Hi @ines-om Thanks for this PR! Since this changes the current search ordering, it would be safer to make it opt-in by adding a new prop, for example: search_order="original"|"index"where original preserves the input options order, and index matches the current behavior (and remains the default). This keeps backward compatibility and also leaves room for future improvements, for example adding a "ranking" mode as in PR #3573 |
When searching in dcc.Dropdown, results should maintain the original option order instead of being reordered by js-search. By creating a Set of search results and filtering the original options array, we preserve order while maintaining performance.
4378ac8 to
54cd282Compare…wn result ordering - Adds new search_order prop with 'index' (default) and 'original' options ordering - Changed 4 integration tests to include new prop
ines-om
commented
Apr 3, 2026
Hi @AnnMarieW Thank you for the feedback! I’ve updated the PR to include the I have verified the implementation and confirmed that the tests added only pass with I hope this implementation is well aligned with the 'ranking' mode PR #3573. Let me know if I should add or change anything! |
I also ran some examples based on this PR and it looks good thanks @ines-om Next steps:
Here's a suggestion for a sample app for the docs: fromdashimportDash, dcc, htmlapp=Dash()
app.layout=dcc.Dropdown(
id="version-dropdown",
options=[
{"label": "Version 3", "value": 3},
{"label": "Version 2", "value": 2},
{"label": "Version 1", "value": 1},
],
placeholder="Search version...",
searchable=True,
# Preserve the original order after searchsearch_order="original",
)
if__name__=="__main__":
app.run(debug=True)
|
ines-om
commented
Apr 6, 2026
Hi @AnnMarieW Just added the changelog! Regarding the docs, I tried to follow the link to the Thank you! |
AnnMarieW
commented
Apr 6, 2026
@ines-om Thanks for the changelog entry! The docs library is private so that will have to be upated by the Plotly team. Thanks for offering to help with that too! |
Uh oh!
There was an error while loading. Please reload this page.
This PR fixes#2989.
When searching in
dcc.Dropdown, search results should be presented in the original option order instead of being reordered byjs-search. This is achieved by creating a Set of the search results and filtering the original options array against it, preserving the intended order.Contributor Checklist
DropdownSearch.tsxto preserve user-defined order in search resultsoptionals
CHANGELOG.md