Skip to content

fix: prevent selection when an open dropdown is disabled - #4548

Open
Xapollon430 wants to merge 1 commit into
Semantic-Org:masterfrom
Xapollon430:codex/dropdown-disable-open-options
Open

Xapollon430 wants to merge 1 commit into
Semantic-Org:masterfrom
Xapollon430:codex/dropdown-disable-open-options

Conversation

@Xapollon430

@Xapollon430 Xapollon430 commented Nov 2, 2026 •

Copy link
Copy Markdown

Problem

I was playing around with the Dropdown component and noticed a bug where:

  1. Open an enabled Dropdown.
  2. Set disabled to true while the menu is open.
  3. Click an option. The selection changes and onChange still fires.

Here is a reproduction video of the issue:

Recorded against published Semantic UI React 2.1.5, before the fix.

semantic-ui-react-disabled-repro.mp4

A React re-render can send disabled=true after the menu is already open. In an application, that could happen when an asynchronous request completes or a timer fires while someone is choosing an option. The case here is the parent control becoming disabled; the options haven't been individually marked disabled.

My first thought was to close the popup, since that is what I observed with a native HTML select in Chromium. The HTML option-picking algorithm also stops without selecting an option when its select is disabled.

Semantic UI React supports a controlled open prop. If the application keeps open={true}, closing the popup internally can disagree with the state the application supplied. I personally prefer keeping the menu visible and preventing selection in that case. Closing on disable is also a reasonable choice, and I'm happy to follow the library's preferred pattern; we just need to account for that controlled open state.

The options inherit the Dropdown's disabled state, and the keyboard selection path checks it too. The current open state is preserved.

I started investigating this interaction while using Hegel to vary component props and Bombadil to exercise UI actions in Anta. I then reproduced this library's behavior separately; the video above is from that reproduction.

Validation

  • The new regression fails on unmodified source and passes with this change in Chromium.
  • Seven Dropdown disabled tests passed in a focused local Karma run. To run them in this environment, I temporarily restricted the test bundle to Dropdown, used the installed Chromium, and supplied placeholder generated documentation metadata; the full suite was not run.

The reproduced release is 2.1.5, while this branch targets the current master source.

@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown

@Xapollon430 is attempting to deploy a commit to the Semantic UI Team on Vercel.

A member of the Team first needs to authorize it.

@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.53%. Comparing base (e0a42b5) to head (3a197ec).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4548   +/-   ##
=======================================
  Coverage   99.53%   99.53%           
=======================================
  Files         186      186           
  Lines        3463     3463           
=======================================
  Hits         3447     3447           
  Misses         16       16           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Xapollon430
Xapollon430 marked this pull request as ready for review November 2, 2026 03:19

This branch has not been deployed

No deployments
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.

1 participant