-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix #13344 Disabled ToolstripMenuItems are no longer highlighted #13354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good. Had you tested with different ToolStripItems, not only menu items. Also test the dark mode.
Please fix the failing tests and see if you can add new ones for this scenario.
And I'd want @merriemcgaw input on the desired menu selection behavior
We can highlight disabled items, but I don't think we should be selecting them as we use the keyboard to navigate over the menu. |
@Epica3055 - we discussed this with Merrie, please copy the |
@Tanya-Solyanik |
Let me clarify. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #13354 +/- ##
===================================================
+ Coverage 61.34314% 62.61551% +1.27237%
===================================================
Files 1547 1561 +14
Lines 158479 159839 +1360
Branches 14751 14915 +164
===================================================
+ Hits 97216 100084 +2868
+ Misses 60561 58979 -1582
- Partials 702 776 +74
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripItem.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes #13344 to ensure that disabled ToolStripMenuItems are no longer highlighted by adjusting their accessibility state and selection behavior. Key changes include updated test expectations for disabled items, modifications to the CanSelect and CanKeyboardSelect properties, and additional gating of accessibility event triggering based on the Enabled state.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripButtonTests.cs | Updated inline test data to expect “Unavailable” states for disabled items |
src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripItem.cs | Modified selection properties and gating of accessibility event triggering based on Enabled |
Comments suppressed due to low confidence (2)
src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripItem.cs:576
- [nitpick] Returning true for CanSelect regardless of the Enabled state represents a significant change in selection logic. Please ensure that all consumers of CanSelect are updated accordingly or add inline documentation to clarify this design decision.
public virtual bool CanSelect => true;
src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripItem.cs:3161
- [nitpick] Using the condition '&& Enabled' when raising accessibility focus events prevents events for disabled items. Please review to ensure that this change does not inadvertently skip required accessibility events when the item state changes.
if (forceRaiseAccessibilityFocusChanged && Enabled)
Fixes #13344
Related background
PR_7611 fixed Issue_7601 that Narrator is reading ToolStripMenuitems even when they are disabled
Proposed changes
CanSelect
True, when selected and disabled don't send acc event.Affected Controls
ToolStrip, MenuStrip, StatusStrip
They all hehave the same
Screenshots
Before
After
Test methodology
Other menuItems
Other possible solutions
1.We can add a switch like
CanSelectWhenDisabled
to let users decide2.We can make disabled items selectable just like Winfows Desktop Context menu, but this could be breaking change.