Conversation
Reviewer's GuideRefactors the TreeView drag-and-drop demo to use an instance-scoped source list and non-static icon items, ensuring consistent state updates when dragging nodes while simplifying the draggable item factory method. Sequence diagram for updated TreeView drag-and-drop handlingsequenceDiagram
actor User
participant TreeViewComponent
participant TreeViews
participant DraggableSourceItems
User->>TreeViewComponent: drag node and drop on target
TreeViewComponent->>TreeViews: OnDragItemEndAsync(context)
activate TreeViews
TreeViews->>DraggableSourceItems: find source by context.Source.Value.Id
DraggableSourceItems-->>TreeViews: source TreeFoo
TreeViews->>DraggableSourceItems: find target by context.Target.Value.Id
DraggableSourceItems-->>TreeViews: target TreeFoo
TreeViews->>TreeViews: update source.ParentId and ordering
TreeViews->>TreeViews: DraggableItems = TreeFoo.CascadingTree(DraggableSourceItems, callback)
TreeViews-->>TreeViewComponent: updated DraggableItems
deactivate TreeViews
TreeViewComponent-->>User: render updated TreeView
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7828 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 764 764
Lines 34142 34142
Branches 4701 4701
=========================================
Hits 34142 34142
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:
|
There was a problem hiding this comment.
Pull request overview
Updates the TreeView sample component to avoid shared/static state in the draggable TreeView demo, which can lead to invalid demo data and navigation failures (“page not available”) across sessions.
Changes:
- Introduces a per-component
DraggableSourceItemsdata source and reuses it during drag operations. - Removes the previously cached static draggable items list and makes
IconItemsinstance-scoped.
Comments suppressed due to low confidence (2)
src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor.cs:96
DraggableItems[0]is accessed unconditionally. IfCascadingTree(DraggableSourceItems)ever returns an empty list (e.g., source data ends up with no root nodes), this will throw and break the sample page. Guard withif (DraggableItems.Count > 0)before indexing, and apply the same pattern to the subsequent[1]/[2]expansions.
DraggableItems = TreeFoo.CascadingTree(DraggableSourceItems);
DraggableItems[0].IsExpand = true;
if (DraggableItems.Count > 1)
{
DraggableItems[1].IsExpand = true;
}
src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor.cs:140
- After rebuilding
DraggableItems, the code indexesDraggableItems[0]without checkingCount. A drag operation can potentially result in a hierarchy with no root nodes, makingCascadingTreereturn an empty list and causing anIndexOutOfRangeException. Add aCount > 0guard (and keep the existingCount > 1/2checks) before settingIsExpand.
DraggableItems = TreeFoo.CascadingTree(DraggableSourceItems, cb);
DraggableItems[0].IsExpand = true;
if (DraggableItems.Count > 1)
{
DraggableItems[1].IsExpand = true;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Link issues
fixes #7827
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Ensure TreeView draggable sample uses an instance-level data source instead of shared static state to avoid cross-page interference.
Bug Fixes:
Enhancements: