Repository navigation
fix(Selector): Bring a selection into view only with focus - #25834
Conversation
Match WinUI's FrameworkElement::HasFocus, which is true when the element or one of its descendants has the focus. Selector relies on it to know whether the list has focus while one of its items does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A ListViewBase or ComboBox scrolled its new selection into view on every selection change. WinUI does it in Selector::SetFocusedItem, only while the list has a focused item, so selecting from code on a list without focus leaves the viewport alone. - Enable the ported scroll in SetFocusedItem (CanScrollIntoView, skipped during collection changes) and drop ScrollSelectionIntoView. - Track the focused item from SelectorItem focus changes (ItemFocused/ItemUnfocused). - Port ListViewBase::OnSelectionChanged: in Multiple/Extended mode only the first selection is brought into view, never during a reorder. - Tests that relied on the old scroll now focus the list first. 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]>
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 242306 found UI Test snapshots differences: Details
|
Ignored until #25835: the dropdown doesn't bring the selected item into view when it opens, on master too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25834/docs/index.html |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 242327 found UI Test snapshots differences: Details
|
|
|
GitHub Issue: closes #25833
PR Type:
🐞 Bugfix
What changed? 🚀
Uno scrolled every new
ListView/GridViewselection into view, even on a list without focus. WinUI only does so while the list has focus (Selector::SetFocusedItemreturns before scrolling when no item is focused). This PR enables Uno's existing port of that path instead of the unconditionalSelector.ScrollSelectionIntoView:FrameworkElement.HasFocusnow counts a focused descendant, like WinUI. A click focuses the row and selects it right away, before the asyncGotFocus, so the list must already report focus for the click to scroll.Selector: dropsScrollSelectionIntoView. The scroll inSetFocusedItemruns again, behindCanScrollIntoView, with the minimalDefaultalignment, and skipped during collection changes (m_inCollectionChange). It portsItemFocused/ItemUnfocused, whichSelectorItemcalls on focus changes to track the focused index. FlipView is left out because it positions its own viewport.ListViewBase.OnSelectionChangedis ported: no scroll inNonemode or during a reorder after drop, andMultiplemode scrolls only for the first selection.Validation:
Given_ListViewBase,Given_ComboBox,Given_FlipView,Given_ListBox,Given_TabView,Given_TreeView,Given_NavigationView,Given_FocusManager: 301 total, 0 failed.Given_ListViewBasestays excluded from WinUI at class level, so CI doesn't run them there.Multipletests fail.Behavior change: setting
SelectedItem/SelectedIndexfrom code on a list that doesn't have focus no longer scrolls it. Apps that relied on that can callScrollIntoViewafter selecting. It's listed under "Behavioral changes" in the Uno 7 migration guide.Not fixed here: a
ComboBoxdoesn't bring an existing selection into view when its dropdown opens. That gap is already on master and is tracked in #25835; this PR addsWhen_ComboBox_Opened_With_Selection_ScrollIntoView, ignored until it's fixed.PR Checklist ✅
Screenshots Compare Test Runresults.The behavior change above is the only impact on existing apps; there is no API change.
🤖 Generated with Claude Code