Repository navigation
fix(TreeView): Don't reselect a node unselected without a container (backport #25800) - #25939
Merged
agneszitte merged 10 commits intoNov 3, 2026
Merged
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]> (cherry picked from commit c82c53e)
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]> (cherry picked from commit 382dde3)
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]> (cherry picked from commit b83f795)
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit b450c33)
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]> (cherry picked from commit c361665)
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit ded8be3)
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 94307ba)
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]> (cherry picked from commit fb219e5)
…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]> (cherry picked from commit a66e0b5)
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]> (cherry picked from commit a3f0c7a)
2 of 5 tasks
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Xiaoy312
enabled auto-merge
November 3, 2026 01:28
agneszitte
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
This is an automatic backport of pull request #25800 done by [Mergify](https://mergify.com).