Skip to content

ComboBox: Prevent selecting disabled items - #662

Open
nurullahturkoglu wants to merge 2 commits into
CodeBeamOrg:devfrom
nurullahturkoglu:fix/combobox-disabled-item-659
Open

nurullahturkoglu wants to merge 2 commits into
CodeBeamOrg:devfrom
nurullahturkoglu:fix/combobox-disabled-item-659

Conversation

@nurullahturkoglu

@nurullahturkoglu nurullahturkoglu commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #659

Disabled MudComboBoxItems could still end up selected. In the browser the item's CSS sets pointer-events: none, so a mouse click never reaches it. In Strict mode, though, typing a disabled item's text and leaving the field selected it. HandleOnClick didn't check Disabled either, which is what the ignored test caught under bUnit.

HandleOnClick now returns early for a disabled item, so neither the selection nor its OnClick runs. ToggleOption ignores disabled items too, so its other callers are covered. The Strict blur lookup skips disabled items, so the typed text is handled like any other text that doesn't match: it's cleared, or the previous value is restored.

I removed the [Ignore] from ComboBox_DisabledItemShouldNotBeSelectable and added tests for OnClick, multi selection, a direct ToggleOption call and the Strict blur case. They fail without the fix, and dotnet test -c Release -f net11.0 passes all 409 tests.

I also checked it on the docs server (Chrome, macOS) with an item in the first example temporarily disabled and Strict turned on. Before, typing "Bar" and leaving the field set Value to Bar. After, the field is cleared and the value stays empty. Typing an enabled item still selects it.

Before:
pr-before

After:
pr-after

@codecov

codecov Bot commented Nov 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.07%. Comparing base (f4a1863) to head (e68f907).

Files with missing lines Patch % Lines
...xtensions/Components/ComboBox/MudComboBox.razor.cs 50.00% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (75.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #662      +/-   ##
==========================================
+ Coverage   67.93%   68.07%   +0.14%     
==========================================
  Files         118      118              
  Lines        8616     8618       +2     
  Branches     1516     1517       +1     
==========================================
+ Hits         5853     5867      +14     
+ Misses       2233     2221      -12     
  Partials      530      530              

☔ 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.

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.

MudComboBoxItem: Disabled items can still be selected by clicking

1 participant