Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix Dropdown Option Removal Regression #2816

Merged
merged 5 commits into from
Apr 9, 2024

Conversation

TillerBurr
Copy link
Contributor

Fixes #2733.

The tests for the option removal only included non-searchable dropdowns.

The problem was that the guard clause would always be false for searchable dropdowns and the props on the component were never updated, even though the React component was showing the expected behavior. Removing the !searchable reintroduced another issue (#2099), so there needed to be a way to know if there was a current search happening or if the options had actually been changed.

Instead of using searchable, create a state that is changed when the input is changed, indicating a search is being done. If there is a current search, don't update the options (and hence, don't render changes), else update the options.

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Set a state variable for the search_value.
    • Use the state to check if it's an actual option change or just a search.
    • Parameterize the dropdown tests to make searchable True and False.
  • 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

@ndrezn ndrezn requested a review from emilykl March 27, 2024 14:20
@TillerBurr
Copy link
Contributor Author

I changed it so it only checks !search_value and no extra state needed. From my testing and the included test, everything works as expected. All dropdown tests are passing locally.

The test could probably be simplified (i.e. 1 or 2 callbacks), but I wanted to make a clear distinction between the removal of the item and then checking the value afterwards.

Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 💃

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] dcc.Dropdown value does not update when an option is removed (regression from #1868)
3 participants