Repository navigation
fix: Reuse ListView containers on drag-drop reorder - #23765
Conversation
On drop, VirtualizingPanelLayout.CompleteReorderingItem called Refresh() unconditionally, recycling every materialized container and re-dealing them to different data, so every row re-templated (the whole-list flicker). Switch to LightRefresh() (re-measure only): it re-arranges items to their final positions while preserving container identity, matching the light path the Android layout already uses by default. Add runtime tests for the four reorder paths (Move, RemoveAt+Insert, real drag-drop, and Refresh isolation). The drag-drop test fails before this change and passes after; the existing reorder/drag tests still pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR fixes Skia/managed ListView drag-drop reorder flicker by avoiding a full container recycle/redeal on drop, keeping realized container identity stable across the reorder (matching the lighter refresh behavior used in other reorder paths).
Changes:
- Switch drop completion (
CompleteReorderingItem) fromRefresh()toLightRefresh()to preserve container identity and avoid full-list re-templating. - Add Skia runtime tests validating container reuse across different reorder/mutation paths, including a pointer-driven drag-drop scenario.
- Add helper utilities to capture and compare containers by data item (rather than by index) across reorders.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.managed.cs |
Use LightRefresh() on reorder completion to avoid recycling/redealing containers on drop. |
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase.cs |
Add runtime tests and helper methods to verify container identity is preserved during reorder operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reword the CaptureContainersByItem doc comment: the helper no longer has a GridView caller, and note that ObservableCollection<string> binds to the IEnumerable<object> parameter via IEnumerable<out T> covariance. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23765/wasm-skia-net9/index.html |
|
|
|
Tick the box to add this pull request to the merge queue (same as
|
GitHub Issue: Tracked internally (client-reported ListView drag-drop reorder flicker). No public issue.
PR Type:
🐞 Bugfix
What changed? 🚀
Reordering a
ListViewby drag-and-drop visibly flickered the whole list — every row re-templated — whereas the Move Up / Move Down buttons did not.On drop,
VirtualizingPanelLayout.CompleteReorderingItemcalledRefresh()unconditionally.Refresh()recycles every materialized container (clearContainer: true) and clears the generator id cache, so on the next measure the containers are re-dealt to different data items — every visible row re-templates (the flicker). The lighterLightRefresh()(used byUpdateReorderingItem/CleanupReordering) just re-measures and preserves container identity.This PR switches the managed drop path to
LightRefresh(). The temp reorder offset is already cleared before the call, so a re-measure re-arranges all items to their final positions while keeping each container instance bound to its data item. This is the same light path the Android layout already takes by default (its heavy recycle is gated behindForceRecycleOnDrop, which is off by default and documented as "known to cause a flicker of the whole list").Scope: managed layout (Skia). GridView on Skia uses a non-virtualizing
WrapPanel, soCompleteReorderingItemis never invoked for it — the change affectsListView(and any real virtualizingItemsStackPanel).Tests — four runtime tests in
Given_ListViewBasecovering the reorder paths, container identity keyed by data item:When_Reorder_Move_ReusesContainers—ObservableCollection.Move(button path)When_Reorder_RemoveInsert_ReusesContainers—RemoveAt+Insert(drag-drop's collection commit)When_Reorder_DragDrop_ReusesContainers— real pointer-driven drag-drop (fails before this change, passes after)When_Layouter_Refresh_RecreatesContainers— isolates thatRefresh()itself churns containersValidated on Skia Desktop: the drag-drop test flips FAIL→PASS with the fix, and the existing reorder/drag tests (
When_UpdateLayout_In_DragDropping,When_Drop_Outside_Bounds,When_UpdateLayout_In_DragDropping_2,When_DragDrop_ItemsSource_Is_Subclass_Of_ObservableCollection,When_INCC_Move_MinimalUpdate) still pass — confirming the dropped item still lands in the correct position via incremental collection-change handling.PR Checklist ✅
Screenshots Compare Test Runresults.