Skip to content

Conversation

Epica3055
Copy link
Member

@Epica3055 Epica3055 commented Apr 23, 2025

Fixes #13344

Related background

PR_7611 fixed Issue_7601 that Narrator is reading ToolStripMenuitems even when they are disabled

Proposed changes

  • Set CanSelect True, when selected and disabled don't send acc event.

Affected Controls

ToolStrip, MenuStrip, StatusStrip
They all hehave the same

Screenshots

Before

Image

After

Issue_13344_01

Issue_13344_07

Test methodology

  • manually

Other menuItems

Issue_13344_05
Issue_13344_03

Issue_13344_06
Issue_13344_04

Other possible solutions

1.We can add a switch like CanSelectWhenDisabled to let users decide
2.We can make disabled items selectable just like Winfows Desktop Context menu, but this could be breaking change.

@Tanya-Solyanik
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@Tanya-Solyanik Tanya-Solyanik left a 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

@merriemcgaw
Copy link
Member

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.

@Tanya-Solyanik
Copy link
Contributor

@Epica3055 - we discussed this with Merrie, please copy the Debug menu behavior - the last reference gif.

@Epica3055
Copy link
Member Author

@Tanya-Solyanik
I don't think Debug menu behavior is what the customer wants. Because it doesn't have highlighted effect when hovered. I added some additional pictures in the description you can see it.

@Tanya-Solyanik
Copy link
Contributor

Let me clarify.
We want to copy up/down arrow navigation from the debug menu in the VS, i.e. both the narrator and the keyboard selection skip the disabled item, but keep the mouse navigation as you implemented in this PR.

Copy link

codecov bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.61551%. Comparing base (88c3a11) to head (78f790f).
Report is 160 commits behind head on main.

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     
Flag Coverage Δ
Debug 62.61551% <ø> (-12.55657%) ⬇️
integration 11.32273% <ø> (-7.54925%) ⬇️
production 40.78835% <ø> (-34.38373%) ⬇️
test 95.69857% <ø> (∅)
unit 38.19131% <ø> (-36.06571%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@Copilot Copilot AI left a 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)

@Epica3055 Epica3055 merged commit 7774491 into dotnet:main Apr 27, 2025
8 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabled ToolstripMenuItems are no longer highlighted [Accessibility] Narrator is reading ToolStripMenuitems even when they are disabled
3 participants