Repository navigation
Fix RadioButton focus rectangle visibility when an image is assigned - #15299
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The localized change preserves existing fallback behavior, includes targeted regression coverage, and has no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes #15289 by keeping the RadioButton keyboard-focus indicator around the text when an image is assigned, preventing oversized images from pushing the indicator outside the visible control.
Changes:
- Uses text bounds for the focus rectangle when both text and an image are present.
- Preserves existing behavior for textless controls and adds geometry and bitmap regression tests across Standard, Flat, and Popup styles.
| File | Description |
|---|---|
| src/test/unit/System.Windows.Forms/System/Windows/Forms/RadioButtonBaseAdapterTests.cs | Adds focus simulation and regression coverage for image sizes, AutoSize, and rendering styles. |
| src/System.Windows.Forms/System/Windows/Forms/Controls/Buttons/ButtonInternal/RadioButtonBaseAdapter.cs | Restricts the focus rectangle to text bounds when text and an image are present. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15299 +/- ##
=============================================
Coverage 37.84861% 37.84861%
=============================================
Files 246 246
Lines 9789 9789
Branches 1031 1031
=============================================
Hits 3705 3705
Misses 5920 5920
Partials 164 164
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Shyam-Gupta
approved these changes
Oct 22, 2026
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 #15289
Root cause
The shared button layout calculates the focus rectangle from the union of the text and image bounds. When
AutoSizeisfalseand the image is larger than the available space, the focus rectangle can extend outside the visible control area, making the dotted focus indicator invisible.Proposed change
TextBoundswhen aRadioButtonhas both text and an image, so the focus indicator surrounds only the text.Customer Impact
Regression?
Risk
Screenshots
Before
After
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow