-
Notifications
You must be signed in to change notification settings - Fork 1k
fix #13677 FontStyle.Bold Not Visually Applied to LinkLabel at Runtime via Code #13681
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
Conversation
…Runtime via Code
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13681 +/- ##
====================================================
- Coverage 97.41503% 76.75799% -20.65704%
====================================================
Files 1192 3256 +2064
Lines 353853 642010 +288157
Branches 5435 47549 +42114
====================================================
+ Hits 344706 492794 +148088
- Misses 8378 145554 +137176
- Partials 769 3662 +2893
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #13677 by restoring the visual Bold style on LinkLabel
when set via code by making the isActive
parameter nullable and only applying bold adjustments when it is explicitly true or false.
- Changed
EnsureLinkFonts
signature to acceptbool? isActive
instead ofbool
- Updated conditional logic to only modify
FontStyle.Bold
whenisActive
is non-null
Comments suppressed due to low confidence (2)
src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs:167
- Changing a public method’s signature from
bool
tobool?
is a breaking API change. Consider adding an overload to preserve backward compatibility or document this change in the public API surface.
bool? isActive = null)
src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs:167
- There don’t appear to be unit tests covering the new
null
case forisActive
. Add tests to verify that leavingisActive
asnull
does not alter the existing default styling behavior.
bool? isActive = null)
src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. @LeafShi1 - I have a few thoughts, but really minor just to make sure we're on the safe side:
Maybe we want @Olina-Zhang have this tested also visually in High Contrast scenarios? Depending on how selection colors are applied, we could consider drawing the offset in the system’s SelectionForeColor (or even a semitransparent black/white shadow) rather than the link color itself, just to guarantee enough contrast under every A11Y theme. But this is only to make it perfect. Let's see, how it really looks, and for now, let's get it in quickly, and then IF we would need to do something, we do that later, in addition.
Disposal sanity check: Let's make sure that the getLinkFont
/ getHoverFont
fields still get disposed when the cell/style gets torn down. (But this is just in case: since you haven’t changed that lifecycle, it should be fine, I assume.)
Nice job, thanks!
(I approve, to not block anything. Feel free to approve yourselves again, should you need to do additional changes, so we have the LinkLabel
fix in quick - and then if necessary for additional A11Y scenarios, we do a follow up. @merriemcgaw FYI.)
@leaf, I usually wouldn't hit merge myself, but I want this in to have further testing. |
/backport to release/9.0 |
Started backporting to release/9.0: https://github.com/dotnet/winforms/actions/runs/16307848441 |
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/winforms/actions/runs/16307852902 |
@LeafShi1 backporting to release/9.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: fix #13677 FontStyle.Bold Not Visually Applied to LinkLabel at Runtime via Code
Using index info to reconstruct a base tree...
A src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Falling back to patching base and 3-way merge...
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Applying: Update LinkUtilities.cs
Using index info to reconstruct a base tree...
A src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Falling back to patching base and 3-way merge...
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Applying: Update LinkUtilities.cs
Using index info to reconstruct a base tree...
A src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Falling back to patching base and 3-way merge...
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Applying: use another approach
Using index info to reconstruct a base tree...
A src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridViewLinkCell.cs
A src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Falling back to patching base and 3-way merge...
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewLinkCell.cs
CONFLICT (content): Merge conflict in src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewLinkCell.cs
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0004 use another approach
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@LeafShi1 backporting to release/8.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: fix #13677 FontStyle.Bold Not Visually Applied to LinkLabel at Runtime via Code
Using index info to reconstruct a base tree...
A src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Falling back to patching base and 3-way merge...
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/LinkUtilities.cs
Applying: Update LinkUtilities.cs
Using index info to reconstruct a base tree...
A src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Falling back to patching base and 3-way merge...
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/LinkUtilities.cs
Applying: Update LinkUtilities.cs
Using index info to reconstruct a base tree...
A src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Falling back to patching base and 3-way merge...
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/LinkUtilities.cs
Applying: use another approach
Using index info to reconstruct a base tree...
A src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridViewLinkCell.cs
A src/System.Windows.Forms/System/Windows/Forms/Controls/Labels/LinkUtilities.cs
Falling back to patching base and 3-way merge...
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.cs
CONFLICT (content): Merge conflict in src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.cs
Auto-merging src/System.Windows.Forms/src/System/Windows/Forms/LinkUtilities.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0004 use another approach
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
…time via Code (#13702) <!-- Please read CONTRIBUTING.md before submitting a pull request --> Backport of #13681 to release/8.0 Fixes #13677 ## Proposed changes - Modified the signature of the `EnsureLinkFonts ` method, removed the bool `isActive ` parameter, and adjusted the related conditional logic and updated the text rendering method of **LinkLabel** in the Active state, by moving the text 1 pixel to the right to achieve a bold effect. <!-- We are in TELL-MODE the following section must be completed --> ## Customer Impact - Allows users to correctly set the **LinkLabel** control to a bold font through `FontStyle.Bold` at runtime ## Regression? - Yes, introduced in #6250 ## Risk - Low <!-- end TELL-MODE --> ## Test methodology <!-- How did you ensure quality? --> - Manual testing
…time via Code (#13703) <!-- Please read CONTRIBUTING.md before submitting a pull request --> Backport of #13681 to release/9.0 Fixes #13677 ## Proposed changes - Modified the signature of the `EnsureLinkFonts ` method, removed the bool `isActive ` parameter, and adjusted the related conditional logic and updated the text rendering method of **LinkLabel** in the Active state, by moving the text 1 pixel to the right to achieve a bold effect. <!-- We are in TELL-MODE the following section must be completed --> ## Customer Impact - Allows users to correctly set the **LinkLabel** control to a bold font through `FontStyle.Bold` at runtime ## Regression? - Yes, introduced in #6250 ## Risk - Low <!-- end TELL-MODE --> ## Test methodology <!-- How did you ensure quality? --> - Manual testing
Fixes #13677
Root cause
This issue was introduced by PR6250 to fix Issue6116
This is one of it's changes.

The new parameter
isActive
is to address DataGridViewLinkCell issue, but it also break other cases.Proposed changes
Regression?
Screenshots
Before
After
Microsoft Reviewers: Open in CodeFlow