-
-
Notifications
You must be signed in to change notification settings - Fork 351
doc(TreeView): add auto expand after drag sample code #6471
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
Reviewer's GuideEnhance TreeView drag-and-drop sample by adding automatic expansion of target nodes via a new callback in CascadingTree, extend the CascadingTree APIs to support expansion callbacks, and clean up sample item labels. Sequence diagram for auto-expanding target node after drag-and-drop in TreeViewsequenceDiagram
actor User
participant TreeViewComponent
participant TreeFoo
participant ExpandableNodeExtensions
participant TreeViewItem
User->>TreeViewComponent: Drag and drop node
TreeViewComponent->>TreeFoo: Call CascadingTree(items, cb)
TreeFoo->>ExpandableNodeExtensions: Call CascadingTree with callback
loop For each item
ExpandableNodeExtensions->>TreeViewItem: Create TreeViewItem
ExpandableNodeExtensions->>ExpandableNodeExtensions: Recursively call CascadingTree for children
alt Callback provided
ExpandableNodeExtensions->>TreeViewItem: Invoke callback (may set IsExpand=true)
end
end
TreeViewComponent->>TreeViewComponent: Set DraggableItems, expand target node
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @ArgoZhang - I've reviewed your changes - here's some feedback:
- Remove the unused
expandNodeIds
variable in OnDragItemEndAsync or integrate it into your expand logic as intended. - The expression‐bodied CascadingTree extension uses square brackets around the LINQ query which isn’t valid C#—refactor it into a proper block or return
ToList()
directly. - Since you removed descriptive suffixes like “(Drop inside blocked)” from the sample items, double-check that the sample behavior and labels still accurately reflect any movement restrictions.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remove the unused `expandNodeIds` variable in OnDragItemEndAsync or integrate it into your expand logic as intended.
- The expression‐bodied CascadingTree extension uses square brackets around the LINQ query which isn’t valid C#—refactor it into a proper block or return `ToList()` directly.
- Since you removed descriptive suffixes like “(Drop inside blocked)” from the sample items, double-check that the sample behavior and labels still accurately reflect any movement restrictions.
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor.Server/Data/TreeFoo.cs:181` </location>
<code_context>
/// <param name="items">数据集合</param>
- public static List<TreeViewItem<TreeFoo>> CascadingTree(IEnumerable<TreeFoo> items) => items.CascadingTree(null, (foo, parent) => foo.ParentId == parent?.Value.Id, foo => new TreeViewItem<TreeFoo>(foo)
+ /// <param name="treeviewItemCallback">节点状态回调方法</param>
+ public static List<TreeViewItem<TreeFoo>> CascadingTree(IEnumerable<TreeFoo> items, Action<TreeViewItem<TreeFoo>>? treeviewItemCallback = null) => items.CascadingTree(null, (foo, parent) => foo.ParentId == parent?.Value.Id, foo => new TreeViewItem<TreeFoo>(foo)
{
Text = foo.Text,
Icon = foo.Icon,
IsActive = foo.IsActive
- });
+ }, treeviewItemCallback);
}
</code_context>
<issue_to_address>
Parameter naming is inconsistent with the extension method.
Please use consistent casing for the parameter name to match the extension method.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6471 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 749 749
Lines 32364 32366 +2
Branches 4572 4573 +1
=========================================
+ Hits 32364 32366 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6470
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Enhance tree view drag-and-drop sample by extending the CascadingTree method with a callback option and updating sample code to auto-expand target nodes after reordering.
New Features:
Enhancements: