-
Notifications
You must be signed in to change notification settings - Fork 1k
Update TreeView's TvnEndLabelEdit method to set label to null when no text has changed #13588
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
Update TreeView's TvnEndLabelEdit method to set label to null when no text has changed #13588
Conversation
… text has changed
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 updates the TreeView’s label edit handling to prevent exceptions when the text remains unchanged.
- Refactors TvnBeginLabelEdit by removing a redundant duplicate condition check.
- Updates TvnEndLabelEdit to pass null for the new label when the text is unchanged, preventing exception scenarios on Enter key presses.
Comments suppressed due to low confidence (1)
src/System.Windows.Forms/System/Windows/Forms/Controls/TreeView/TreeView.cs:2604
- The condition continues to use the original newText variable rather than the value passed via e.Label. To ensure that the node edit is only finished when a change has occurred, consider checking e.Label instead of newText.
if (newText is not null && !e.CancelEdit && node is not null)
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.
All LGTM!
src/System.Windows.Forms/System/Windows/Forms/Controls/TreeView/TreeView.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.
Looks good to me.
If you decide for the simplified term, in which case you need a new approval, ask a colleague to approve - it's fine to merge from my side.
…prove readability
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13588 +/- ##
===================================================
+ Coverage 76.60518% 76.60716% +0.00197%
===================================================
Files 3235 3236 +1
Lines 639321 639452 +131
Branches 47314 47319 +5
===================================================
+ Hits 489753 489866 +113
- Misses 145996 146065 +69
+ Partials 3572 3521 -51
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
… text has changed (dotnet#13588) * Update TreeView's TvnEndLabelEdit method to set label to null when no text has changed
/backport to release/9.0 |
Started backporting to release/9.0: https://github.com/dotnet/winforms/actions/runs/15725596969 |
Fixes #13583
Proposed changes
TvnEndLabelEdit
method to set label to null when no text has changedCustomer Impact
Regression?
Risk
Screenshots
Before
Pressing the Enter key when a TreeNode enters the edit state will cause an exception
After
When a TreeNode enters the edit state, press the Enter key, the node will exit the edit state
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow