Fix ToolStripDropDownMenu scroll boundary handling to prevent out-of-range and unintended dropdown dismissal#14490
Open
LeafShi1 wants to merge 2 commits intodotnet:mainfrom
Conversation
…range and unintended dropdown dismissal
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ToolStripDropDownMenu scrolling boundary behavior so scroll buttons reflect actual scrollability, prevent out-of-range scrolling at boundaries, and avoid unintended dropdown dismissal when interacting with scroll buttons.
Changes:
- Replaces edge-based
Rectangle.Contains(...)checks with explicit “fully visible” / “intersects viewport” checks. - Updates scroll button enable/disable logic and adds early-return guards to avoid invalid scrolling paths.
- Marks
ToolStripScrollButtonas navigation-only (SupportsItemClick = false) and adds regression unit tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripDropDownMenu.cs | Adjusts visibility math, scroll boundary logic, and scroll-button status calculation. |
| src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripScrollButton.cs | Prevents scroll buttons from participating in item-click routing to avoid AutoClose dismissal. |
| src/test/unit/System.Windows.Forms/ToolStripDropDownMenuTests.cs | Adds/updates unit tests covering scroll boundary and scroll-button click behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
Please address the Copilot suggestions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #6650
Proposed changes
fully visible/intersects viewport) instead of edge-basedRectangle.Contains(...).ScrollInternal(bool up)when the target scroll button is already disabled.ToolStripScrollButtonas navigation-only (SupportsItemClick = false) so scrolling does not trigger dropdown auto-close behavior.Customer Impact
Regression?
Risk
Screenshots
Before
The ToolStripScrollDownButton is still enabled when displaying the last dropdown item, and in this case, an exception pops up when clicking that ToolStripScrollDownButton again
After
When go through the last dropdown item, the ToolStripScrollDownButton is disabled
AfterChanges.mp4
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow