Repository navigation
fix(TreeView): Don't reselect a node unselected without a container - #25800
Conversation
In single selection, selecting a node unselects the previous one through NotifyContainerOfSelectionChange. When the previous node had no container, the Uno-only fallback there assigned it to TreeViewList.SelectedItem even though it was being unselected: that selected it again and scrolled it into view, then the clicked node's own selection scrolled back. Only force a node that is being selected onto the list. An unselection without a container is not written back to the item's two-way IsSelected binding, so the data still says true and the container would select the node again when it is realized. Record such unselections with the current selection count; when the container is prepared after another node was selected, ignore the stale value and reset the container's IsSelected so the binding receives the unselection. Fixes #25796 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Selector.PrepareContainerForItemOverride already sets the container's IsSelected from the list's selection after the stale binding value is pushed, which writes the unselection back through the binding. The reset after the base call never found IsSelected still set. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Record an unselection made without a container on the TreeViewNode instead of a ConditionalWeakTable keyed by the list item. In content mode the key was the item itself, so boxed value types never matched and equal strings collided. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Uno 7.0 has no native Android or iOS renderer, so the __ANDROID__ || __APPLE_UIKIT__ ignores never apply. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The #15214 workaround selects a realized node through ListViewModel.UpdateSelection, which doesn't clear the other node in single selection, so also check that only one node is selected and that SelectedNodes and SelectedItems agree (content-mode aware). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ainer When_Select_Last_Root_Node_Then_Click_First_Node passed with the NotifyContainerOfSelectionChange fallback removed, since it only compared SelectedNodes and SelectedItems. Also check that TreeView.SelectedItem follows Node 50 while it has no container. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Checked against WinAppSDK 1.7: after scrolling back, WinUI selects the previously selected row again and then clears the selection, while Uno keeps the clicked row. The collapse/re-expand case matches WinUI. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The build 242077 found UI Test snapshots differences: Details
|
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 242200 found UI Test snapshots differences: Details
|
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
@Mergifyio backport release/stable/6.7 servicing/6.8 |
✅ Backports have been createdDetails
|
…r-25800 fix(TreeView): Don't reselect a node unselected without a container (backport #25800)
…6.7/pr-25800 fix(TreeView): Don't reselect a node unselected without a container (backport #25800)
#25800 hooked Selector.ChangeSelectedItem, which the ported Selector no longer has. Intercept NotifyListItemSelected instead, so a stale IsSelected pushed while a container is prepared still can't select. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNu1xx5N7UDrHyMDxMPa
The #25800 tests scrolled row 0 away, but ItemsStackPanel keeps it realized as its special item, as WinUI does, and never recycles the focused container. Use row 1 and move focus off it first. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNu1xx5N7UDrHyMDxMPa
#25800 hooked Selector.ChangeSelectedItem, which the ported Selector no longer has. Intercept NotifyListItemSelected instead, so a stale IsSelected pushed while a container is prepared still can't select. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNu1xx5N7UDrHyMDxMPa
The #25800 tests scrolled row 0 away, but ItemsStackPanel keeps it realized as its special item, as WinUI does, and never recycles the focused container. Use row 1 and move focus off it first. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNu1xx5N7UDrHyMDxMPa
GitHub Issue: closes #25796
PR Type:
🐞 Bugfix
What changed? 🚀
In a single-selection
TreeView, clicking a row after scrolling away from the selected row made the viewport jump back toward the previous row, andSelectionChangedre-added the previous row.Selecting a node unselects the previous one through
TreeViewViewModel.NotifyContainerOfSelectionChange. When the previous node had no container, an Uno-only fallback there assigned it toTreeViewList.SelectedItemeven though it was being unselected, which selected it again and scrolled it into view.TreeViewItem.IsSelectedbinding, the unselection of a row without a container never reaches its data, so the row would select itself again once realized (through theTreeViewshould start withSelectedItemselected #15214 workaround). Such unselections are now recorded on theTreeViewNodewith a selection count; when the container is prepared after a newer selection, the staleIsSelected = trueis ignored andSelectorwrites the unselection back to the binding.The first commit is a contributed patch, kept as is; the following commits refine it (node-based marker instead of a
ConditionalWeakTable, a dead reset removed) and tighten the tests.Tests
New
Given_TreeViewruntime tests: click after scrolling away (no viewport movement in either direction, previous row not re-added), programmatic replacement (singleSelectionChanged, no transient null), scroll-back and collapse/re-expand with anIsSelectedbinding (old row stays unselected, single selection,SelectedNodes/SelectedItemsin sync), and a port of the MUXTreeViewSelectRegressionTest.Validated on Skia Desktop (Windows): all 31
Given_TreeViewtests pass. Disabling each part of the fix makes at least one test fail. With the repro from the issue (20 automated iterations), stock Uno.WinUI 7.0.0-dev.2494 jumps and re-adds the previous row on every iteration; with the fix, none (0/20, on the first commit and again on the final commits).Given_TreeViewis excluded on native WinUI, so the binding scenarios were compared with a standalone WinAppSDK 1.7 app: WinUI also leaves the previous row's boundIsSelectedattruewhile it has no container, but when that row is scrolled back into view it selects it again and then clears the selection, while Uno keeps the clicked row. The tests note this divergence.Related
Selector.ScrollSelectionIntoViewscrolls everyListViewBaseon any selection change, which WinUI doesn't, so clicking a row cut off at the viewport edge can still shift the viewport by a few pixels; to be handled separately.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code