Skip to content

Fix PropertyGrid Tab navigation regression caused by ToolStrip keyboard focus changes#14434

Open
LeafShi1 wants to merge 3 commits intodotnet:mainfrom
LeafShi1:Fix_14421_PropertyGrid_breaks_Tab_navigation_cycle
Open

Fix PropertyGrid Tab navigation regression caused by ToolStrip keyboard focus changes#14434
LeafShi1 wants to merge 3 commits intodotnet:mainfrom
LeafShi1:Fix_14421_PropertyGrid_breaks_Tab_navigation_cycle

Conversation

@LeafShi1
Copy link
Copy Markdown
Member

@LeafShi1 LeafShi1 commented Mar 30, 2026

Fixes #14421

Root cause

  • PR 13034 changed ToolStrip so that whenever a ToolStrip receives focus (WM_SETFOCUS), it becomes the active ToolStrip in ToolStripManager.ModalMenuFilter.
  • For normal top-level menu/toolbar strips this is desired (to fix 12916), but for the inner PropertyGridToolStrip it means:
    • Entering / staying in menu mode when focus moves to the PropertyGrid toolbar.
    • Dialog-level focus routing and Tab handling start to respect this active ToolStrip state.
  • With a PropertyGrid on the form, this extra menu-mode/ActiveToolStrip state causes the second and subsequent Tab cycles to be biased toward the PropertyGrid and its toolbar, so some sibling controls (e.g. Button, ComboBox) are skipped — a regression vs .NET Framework and .NET 8/9.

Proposed changes

  • In PropertyGridToolStrip (the inner ToolStrip used by PropertyGrid), override WndProc and, on WM_SETFOCUS, remove this ToolStrip from ToolStripManager.ModalMenuFilter’s active ToolStrip list and exit menu mode if it was the active one.
  • This isolates PropertyGrid’s internal toolbar from the global menu-mode / ActiveToolStrip mechanics introduced in PR 13034 , while leaving all other ToolStrips (including the ones involved in 12916) using the existing behavior unchanged.

Customer Impact

  • PropertyGrid no longer interferes with the form’s Tab cycle, all TabStop controls (Buttons, ComboBox, PropertyGrid, etc.) are visited in order on every Tab cycle

Regression?

  • Yes

Risk

  • minimal

Screenshots

Before

  • First Tab cycle: all controls are reachable ✔
  • Second and subsequent cycles:

Some controls (e.g., ComboBox, one Button) are skipped ❌
Focus repeatedly lands on PropertyGrid and a subset of controls ❌

PropertyGridIssue.mp4

After

All TabStop controls (Buttons, PropertyGrid, etc.) are visited in order on every Tab cycle

AfterChanges.mp4

Test methodology

  • Manually

Test environment(s)

  • .net 11.0.0-preview.3.26174.112
Microsoft Reviewers: Open in CodeFlow

Copy link
Copy Markdown
Contributor

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

Fixes a WinForms PropertyGrid Tab navigation regression introduced by global ToolStrip “active ToolStrip / menu mode” focus handling changes, by preventing the inner PropertyGridToolStrip from remaining active in ToolStripManager.ModalMenuFilter when it receives focus.

Changes:

  • Override PropertyGridToolStrip.WndProc to detect WM_SETFOCUS and remove the inner ToolStrip from ModalMenuFilter’s active ToolStrip queue.
  • Exit menu mode when the PropertyGridToolStrip was the active ToolStrip and no other active ToolStrip remains.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Removed reference to global ToolStrip menu mode handling in comment.
@LeafShi1 LeafShi1 added the waiting-review This item is waiting on review by one or more members of team label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label waiting-review This item is waiting on review by one or more members of team

Projects

None yet

3 participants