Skip to content

Fix #2989: dcc.Dropdown options order preserved during search#3680

Open
ines-om wants to merge 2 commits intoplotly:devfrom
ines-om:fix-dccDropdown-order
Open

Fix #2989: dcc.Dropdown options order preserved during search#3680
ines-om wants to merge 2 commits intoplotly:devfrom
ines-om:fix-dccDropdown-order

Conversation

@ines-om
Copy link
Copy Markdown

@ines-om ines-om commented Mar 22, 2026

This PR fixes #2989.

When searching in dcc.Dropdown, search results should be presented in the original option order instead of being reordered by js-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

  • I have broken down my PR scope into the following TODO tasks
    • Implement Set-based filtering in DropdownSearch.tsx to preserve user-defined order in search results
    • Add tests for various option ordering scenarios, including ordering in multi-value dropdowns
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

@AnnMarieW
Copy link
Copy Markdown
Collaborator

Hi @ines-om

Thanks for this PR!
Note – this also closes #2667.

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.
@ines-om ines-om force-pushed the fix-dccDropdown-order branch from 4378ac8 to 54cd282 Compare April 3, 2026 10:41
@ines-om ines-om requested a review from KoolADE85 as a code owner April 3, 2026 10:41
…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
Copy link
Copy Markdown
Author

ines-om commented Apr 3, 2026

Hi @AnnMarieW

Thank you for the feedback! I’ve updated the PR to include the search_order prop as suggested.

I have verified the implementation and confirmed that the tests added only pass with search_order='original', as 'index' (the default) maintains the previous behavior.

I hope this implementation is well aligned with the 'ranking' mode PR #3573.

Let me know if I should add or change anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dcc.dropdown options order not consistent during search

3 participants