Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset MouseIsOver when the control loses focus #12598

Conversation

LeafShi1
Copy link
Member

@LeafShi1 LeafShi1 commented Dec 6, 2024

Fixes #12590

Root Cause

In order to fix the flickering issue#2053861, we modified the drawing logic of ComboBox in #11529

When FlatStyle == FlatStyle.Popup and the control gets the focus or the mouse entering, draw the black border of the popup instead of re-rendering the entire control

This leads to the current issue. When the drop-down box is expanded by the mouse, and the focus is moved to the property page using Tab, FlatStyle is changed to popup, and then the RightToLeft property is modified

At this time, the conditions for drawing the Popup border are met (i.e. FlatStyle == FlatStyle.Popup and MouseIsOver=true), which causes DrawFlatCombo not to be executed

Proposed changes

  • Set MouseIsOver = false in OnLostFocus method of ComboBox.cs

Customer Impact

  • ComboBox dropdown button can be shown normally when switching RightToLeft property, or recreating the combobox for any other reason.

Regression?

  • Yes

Risk

  • Minimal

Screenshots

Before

When change the RightToLeft property after expanding the Popup FlatStyle comboBox, the dropdown button on the comboBox disappeared
Image

After

The dropdown button on the comboBox can be show normally
AfterChanges

Test methodology

  • Manually

Test environment(s)

  • .net 10.0.0-alpha.1.24605.1
Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.

Project coverage is 76.03698%. Comparing base (af49f16) to head (75ca31f).
Report is 153 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #12598         +/-   ##
===================================================
+ Coverage   75.73242%   76.03698%   +0.30455%     
===================================================
  Files           3153        3164         +11     
  Lines         635807      639335       +3528     
  Branches       46975       47188        +213     
===================================================
+ Hits          481512      486131       +4619     
+ Misses        150870      149697       -1173     
- Partials        3425        3507         +82     
Flag Coverage Δ
Debug 76.03698% <86.20690%> (+0.30455%) ⬆️
integration 18.15167% <0.00000%> (-0.10286%) ⬇️
production 49.79835% <20.00000%> (+0.49282%) ⬆️
test 97.02935% <100.00000%> (-0.02059%) ⬇️
unit 47.02069% <20.00000%> (+0.75762%) ⬆️

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

@LeafShi1 LeafShi1 changed the title Fix 12590 combo box dropdown buttonn disappear Fix 12590 combo box dropdown button disappear Dec 6, 2024
@LeafShi1 LeafShi1 changed the title Fix 12590 combo box dropdown button disappear Reset MouseIsOver when the control loses focus Dec 6, 2024
@LeafShi1 LeafShi1 added the waiting-review This item is waiting on review by one or more members of team label Dec 6, 2024
@ricardobossan
Copy link
Member

I proceeded to test this PR and the issue has been resolved:

after

All LGTM!

@Tanya-Solyanik Tanya-Solyanik added waiting-author-feedback The team requires more information from the author and removed waiting-review This item is waiting on review by one or more members of team labels Dec 8, 2024
@dotnet-policy-service dotnet-policy-service bot removed the waiting-author-feedback The team requires more information from the author label Dec 9, 2024
@Tanya-Solyanik Tanya-Solyanik added the waiting-author-feedback The team requires more information from the author label Dec 9, 2024
@dotnet-policy-service dotnet-policy-service bot removed the waiting-author-feedback The team requires more information from the author label Dec 11, 2024
@LeafShi1 LeafShi1 added the waiting-review This item is waiting on review by one or more members of team label Dec 13, 2024
@LeafShi1 LeafShi1 added the waiting-for-testing The PR is awaiting manual testing by the primary team; no action is yet required from the author(s) label Dec 20, 2024
@LeafShi1
Copy link
Member Author

LeafShi1 commented Dec 25, 2024

The first repair idea is changing MouseIsOver to False when the control loses focus, but there is a problem here that the mouse is actually still in the hovering state when the control loses focus, as shown in the figure below. When the focus is switched using Tab, the mouse hovering position remains unchanged. At this time, MouseIsOver=false will cause DrawFlatCombo to be executed and the Popup's black border will disappear.
ActualResult

The correct behavior should be that the black border of the Popup always exists when switching the RightToLeft property value
ExpectedResult

Therefore, when changing the property value while the mouse is hovering, the control must be drawn in its basic form before drawing the black border of the Popup. So I redrawn the DropDown button when executing DrawPopUpCombo in the latest commit

This inevitably causes the DropDown button to flicker when the cursor moves between the DropDown button and the edit box
AfterChange

@Tanya-Solyanik Do you have other suggestions?

@LeafShi1 LeafShi1 removed the waiting-for-testing The PR is awaiting manual testing by the primary team; no action is yet required from the author(s) label Dec 25, 2024
@Tanya-Solyanik
Copy link
Member

Let's revert the fix for the flickering issue#2053861, as he regression it introduced is worse than the original issue. and copy the flickering bug to the winforms GH repo

@Tanya-Solyanik Tanya-Solyanik added waiting-author-feedback The team requires more information from the author and removed waiting-review This item is waiting on review by one or more members of team labels Jan 8, 2025
@Tanya-Solyanik Tanya-Solyanik added the 💥 regression-release Regression from a public release label Jan 8, 2025
@LeafShi1
Copy link
Member Author

LeafShi1 commented Jan 9, 2025

Let's revert the fix for the flickering issue#2053861, as he regression it introduced is worse than the original issue. and copy the flickering bug to the winforms GH repo

Revert revert the PR #12737 and close this one. Create a new bug #12739 for flickering issue.

@LeafShi1 LeafShi1 closed this Jan 9, 2025
@dotnet-policy-service dotnet-policy-service bot added untriaged The team needs to look at this issue in the next triage and removed waiting-author-feedback The team requires more information from the author labels Jan 9, 2025
@LeafShi1 LeafShi1 deleted the Fix_12590_ComboBoxDropdownButtonnDisappear branch January 9, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💥 regression-release Regression from a public release untriaged The team needs to look at this issue in the next triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ComboBox dropdown button disappear when switching RightToLeft property
3 participants