winforms icon indicating copy to clipboard operation
winforms copied to clipboard

fix #13400 Cannot enter characters when adding ToolStripMenuItem1 and then adding ToolStripMenuItem2 after pressing enter in DemoConsole application

Open Epica3055 opened this issue 8 months ago • 2 comments

Fixes #13400

Proposed changes

This issue is introduced by pull/13034, this is the change made by it.

    protected override void WndProc(ref Message m)
    {
        if (m.MsgInternal == PInvokeCore.WM_SETFOCUS)
        {
            SnapFocus((HWND)(nint)m.WParamInternal);

+            // For fix https://github.com/dotnet/winforms/issues/12916
+           ToolStripManager.ModalMenuFilter.SetActiveToolStrip(this);
        }
  ....

In my debugging, I found that ToolStripManager.ModalMenuFilter.SetActiveToolStrip(this); got invoked too many times even ToolStrip didn't lost focus, which I think caused the issue.

So I exclude some cases.

Screenshots

Before

https://github.com/user-attachments/assets/1e6fe900-449b-43bd-bfd1-e0c714f73a84

After

Issue_13400_02 Issue_13400_03

Test methodology

  • manual

Epica3055 avatar May 07 '25 03:05 Epica3055

Codecov Report

:x: Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 76.59942%. Comparing base (71a8e95) to head (6382336). :warning: Report is 249 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13420         +/-   ##
===================================================
- Coverage   76.60371%   76.59942%   -0.00430%     
===================================================
  Files           3230        3230                 
  Lines         639097      639108         +11     
  Branches       47289       47291          +2     
===================================================
- Hits          489572      489553         -19     
- Misses        145953      145980         +27     
- Partials        3572        3575          +3     
Flag Coverage Δ
Debug 76.59942% <66.66667%> (-0.00430%) :arrow_down:
integration 18.78841% <66.66667%> (+0.00032%) :arrow_up:
production 51.00244% <66.66667%> (-0.00859%) :arrow_down:
test 97.40411% <ø> (ø)
unit 48.40883% <66.66667%> (-0.01024%) :arrow_down:

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

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 07 '25 03:05 codecov[bot]

LGTM! To avoid causing other regressions, a test is needed here.

LeafShi1 avatar Jun 16 '25 09:06 LeafShi1

I have slightly stomach aches with this, but I cannot put my finger on it. Can you test if this would affect

a) A hosted Control (TextBox, ComboBox, UserControl with other controls) inside of a ToolStrip? b) A TextBox/ComboBox in a overflow menu?

Thanks!

KlausLoeffelmann avatar Jul 02 '25 01:07 KlausLoeffelmann

It seems fine. 🙂 @KlausLoeffelmann 13420_01

Epica3055 avatar Jul 02 '25 09:07 Epica3055

Close this pr. it's a little risky.

Epica3055 avatar Sep 04 '25 09:09 Epica3055