Fix ToolStripMenuItem character input in design mode #14078
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #13234
Proposed changes
IsInDesignModecheck before callingSetActiveToolStrip(this)inWM_SETFOCUShandlerPR #13034 fixed #12916 by calling
SetActiveToolStrip(this)onWM_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.This follows the existing pattern at line 4614:
if (!IsDropDown && !IsInDesignMode).Customer Impact
Regression?
Risk
Test methodology
IsInDesignModechecks in same methodWarning
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/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)/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:
</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
✨ 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