dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.35k stars 965 forks source link

Weird display when hovering to ToolStripComboBox drop down arrow #11760

Closed Syareel-Sukeri closed 1 month ago

Syareel-Sukeri commented 1 month ago

.NET version

9.0.100-preview.7.24371.4 with dlls built from winforms repo of main branch. It cannot be reproduced with .NET SDK.

Did it work in .NET Framework?

No

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

Yes, this is a regression issue. Not reproduce on .NET 8.0

Issue description

When hovering over drop-down arrow of ToolStripComboBox, an additional blue hover effect appears outside the icon. This issue can only be reproduced with ToolStripComboBox which is in ContextMenuStrip, ToolStrip, MenuStrip. The issue cannot be reproduced with normal ComboBox.

https://github.com/user-attachments/assets/65127428-e7df-4c92-878d-def027ca0be6

Steps to reproduce

  1. Create a WinForms .NET 9.0 project.
  2. Add a ToolStrip component to the form.
  3. Click the drop-down arrow on the ToolStrip to open the list of available items.
  4. Choose ComboBox from the list to add it to the ToolStrip.
  5. Build and run project.
  6. Hover to drop-down arrow of the ToolStripComboBox and observe the result.
Olina-Zhang commented 1 month ago

Give a screenshot of expected result and actual result: image

LeafShi1 commented 1 month ago

In order to make the combo button look thinner, ToolStripComboBox was redrawn based on the original ComboBox. The original button was drawn in two parts (_dropDownRect and _whiteFillRect), and PR #11529 canceled the redrawing of the entire comboBox when the mouse hovered to solve the flickering problem, which caused this problem.

image

There are two solutions

  1. When the target control is ToolStripComboBox, revert the changes of PR #11529, but this will redraw the entire comboBox when the mouse hovers, it will cause flickering. KeepSmallButton

  2. No longer redraw the ToolStripComboBox, so that its appearance is consistent with the normal ComboBox RemoveSmallButton

I submitted a PR #11761, commit1 adopted solution 1, and commit2 adopted solution 2

What modification do you think is more appropriate? Please give me some suggestions

@Tanya-Solyanik

Tanya-Solyanik commented 1 month ago

@LeafShi1 - changing width of the DropDown button in ToolStripComboBox will be a breaking change as it will leave less room for the content and somebody's text will get truncated. Unfortunately we should partially revert the "flickering fix", i.e. go with commit 1

Philip-Wang01 commented 1 month ago

Verified this issue in the latest .NET 9.0.100-rc.1.24407.33, it was fixed: No additional blue hover effect appears outside the icon.

https://github.com/user-attachments/assets/c79068b0-5a75-4021-a533-30ca3eba4f1e

Nora-Zhou01 commented 1 week ago

Verified the issue with .NET 9.0.100-rc.1.24422.10 test pass build that the issue has been fixed, which have the same results as above.