Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 25, 2025

Fixes #13234

Proposed changes

  • Add IsInDesignMode check before calling SetActiveToolStrip(this) in WM_SETFOCUS handler
  • Prevents modal menu mode from intercepting keyboard input in design surfaces

PR #13034 fixed #12916 by calling SetActiveToolStrip(this) on WM_SETFOCUS, but this unconditionally enters modal menu mode which redirects keyboard input to the ToolStrip. In design mode (e.g., DemoConsole), this prevents text entry when editing menu items.

if (!IsInDesignMode)
{
    ToolStripManager.ModalMenuFilter.SetActiveToolStrip(this);
}

This follows the existing pattern at line 4614: if (!IsDropDown && !IsInDesignMode).

Customer Impact

  • Users of custom design surfaces (like DemoConsole) can now enter text when adding ToolStripMenuItems
  • No impact to Visual Studio designer (confirmed not to reproduce there)

Regression?

Risk

  • Low: minimal change, follows existing pattern, only affects design mode behavior

Test methodology

  • Code review verified pattern consistency with existing IsInDesignMode checks in same method
  • Issue confirmed to not reproduce in VS designer per comment from @ricardobossan

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • st8vsblobprodcus339.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/winforms/winforms/.dotnet/dotnet /home/REDACTED/work/winforms/winforms/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/winforms/winforms/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/winforms/winforms/artifacts/toolset/11.0.0-beta.25571.109.txt (dns block)
    • Triggering command: /home/REDACTED/work/winforms/winforms/.dotnet/dotnet dotnet build --no-restore (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Cannot enter characters when adding ToolStripMenuItem1 and then adding ToolStripMenuItem2 after pressing enter in DemoConsole application</issue_title>
<issue_description>### .NET version

main branch of WinForms repo

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes, this is a regression issue. Not repro on .NET 9.0 from Release/9.0 branch of WinForms repo.

release9.0.mp4

Issue description

Actual result:
Cannot enter characters when adding ToolStripMenuItem1 and then adding ToolStripMenuItem2 after pressing enter in DemoConsole application.

cannot.input.mp4

Expected result:
Characters can be entered when adding ToolStripMenuItem1 and then adding ToolStripMenuItem2 after pressing enter in DemoConsole application.

framework.not.repro.mp4

Steps to reproduce

Test sample: DemoConsole bases on main branch in Winforms repo.

More info:

  1. This issue rerpo in ContextMenuStrip/MenuStrip/ToolStrip/BindingNavigator control in DemoConsole application.
    </issue_description>

Comments on the Issue (you are @copilot in this section)

@merriemcgaw @LeafShi1 can your team look into this one? @ricardobossan The issue is caused by commit #13034: `fix #12916 Cannot use down to expand ToolStripDropDownButton in toolStrip2 after using right/Left to collapse ToolStripDropDownButton in toolStrip1`.

Still need to find a solution that resolves both this regression and the original problem from #12916 without reintroducing either.

git bisect log

git bisect start
status: waiting for both good and bad commits
good: [78c7bb8] System.Data.SqlClient - use version recommended by the SQL team, I couldn't find v5, not sure if it exists, we are not referencing this package right ow, so this is not a problem. Nuget.Packaging - use version that does not pull in vulnerable System.Formats.Asn1 (v8.0,0) Change in the VB test project - this assembly is not references directly, transitive versions can be resolved from the central packaging
git bisect good 78c7bb8
status: waiting for bad commit, 1 good commit known
bad: [9092b06] [main] Update dependencies from dotnet/runtime (#13363)
git bisect bad 9092b06
bad: [1a43082] Ensure that System.Drawing facade assembly is built before the tests that consume it are. (#13119)
git bisect bad 1a43082
bad: [1a43082] Ensure that System.Drawing facade assembly is built before the tests that consume it are. (#13119)
git bisect bad 1a43082
good: [707898d] [main] Update dependencies from dotnet/arcade (#13032)
git bisect good 707898d
bad: [316a77b] Remove extra dot at the end of resource string (#13091)
git bisect bad 316a77b
bad: [5e8147d] Resizes DemoConsole project's MainForm for convenience and to make everything visible in the surface designer (#13050)
git bisect bad 5e8147d
bad: [6e112b8] fix #12916 Cannot use down to expand ToolStripDropDownButton in toolStrip2 after using right/Left to collapse ToolStripDropDownButton in toolStrip1 (#13034)
git bisect bad 6e112b8
good: [e9f1c43] Enable nullability in DesignerActionMethodItem (#12676)
git bisect good e9f1c43
good: [e65c611] [main] Update dependencies from dotnet/arcade (#13038)
git bisect good e65c611
good: [2dc1fbe] Add code coverage for ControlCodeDomSerializer (#13011)
git bisect good 2dc1fbe
first bad commit: [6e112b8] fix #12916 Cannot use down to expand ToolStripDropDownButton in toolStrip2 after using right/Left to collapse ToolStripDropDownButton in toolStrip1 (#13034)

@ricardobossan<...

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Microsoft Reviewers: Open in CodeFlow

Copilot AI changed the title [WIP] Fix input issue with ToolStripMenuItem in DemoConsole application Fix ToolStripMenuItem character input in design mode Nov 25, 2025
Copilot AI requested a review from LeafShi1 November 25, 2025 02:28
Copilot finished work on behalf of LeafShi1 November 25, 2025 02:28
@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.15474%. Comparing base (09c759b) to head (4714510).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #14078         +/-   ##
===================================================
- Coverage   77.16719%   77.15474%   -0.01246%     
===================================================
  Files           3279        3279                 
  Lines         645317      645320          +3     
  Branches       47718       47719          +1     
===================================================
- Hits          497973      497895         -78     
- Misses        143657      143729         +72     
- Partials        3687        3696          +9     
Flag Coverage Δ
Debug 77.15474% <100.00000%> (-0.01246%) ⬇️
integration 18.98213% <100.00000%> (-0.03711%) ⬇️
production 52.01845% <100.00000%> (-0.02764%) ⬇️
test 97.40749% <ø> (ø)
unit 49.47212% <100.00000%> (-0.00053%) ⬇️

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.

@dotnet-policy-service dotnet-policy-service bot added the draft draft PR label Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

draft draft PR

Projects

None yet

2 participants