Skip to content

fix(Selector): Bring a selection into view only with focus - #25834

Merged
MartinZikmund merged 5 commits into
masterfrom
dev/xygu/20261029/selection-scroll-focus-gated
Nov 4, 2026
Merged

MartinZikmund merged 5 commits into
masterfrom
dev/xygu/20261029/selection-scroll-focus-gated

Conversation

@Xiaoy312

@Xiaoy312 Xiaoy312 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25833

PR Type:

🐞 Bugfix

What changed? 🚀

Uno scrolled every new ListView/GridView selection into view, even on a list without focus. WinUI only does so while the list has focus (Selector::SetFocusedItem returns before scrolling when no item is focused). This PR enables Uno's existing port of that path instead of the unconditional Selector.ScrollSelectionIntoView:

  • FrameworkElement.HasFocus now counts a focused descendant, like WinUI. A click focuses the row and selects it right away, before the async GotFocus, so the list must already report focus for the click to scroll.
  • Selector: drops ScrollSelectionIntoView. The scroll in SetFocusedItem runs again, behind CanScrollIntoView, with the minimal Default alignment, and skipped during collection changes (m_inCollectionChange). It ports ItemFocused/ItemUnfocused, which SelectorItem calls on focus changes to track the focused index. FlipView is left out because it positions its own viewport.
  • ListViewBase.OnSelectionChanged is ported: no scroll in None mode or during a reorder after drop, and Multiple mode scrolls only for the first selection.

Validation:

  • Skia desktop: Given_ListViewBase, Given_ComboBox, Given_FlipView, Given_ListBox, Given_TabView, Given_TreeView, Given_NavigationView, Given_FocusManager: 301 total, 0 failed.
  • Native WinUI (WinAppSDK): the new tests pass 7/7. The click test is ignored there, since the WinUI head has no input injector. Given_ListViewBase stays excluded from WinUI at class level, so CI doesn't run them there.
  • Fail-before: on master sources, the no-focus, focus-left and Multiple tests fail.

Behavior change: setting SelectedItem/SelectedIndex from code on a list that doesn't have focus no longer scrolls it. Apps that relied on that can call ScrollIntoView after selecting. It's listed under "Behavioral changes" in the Uno 7 migration guide.

Not fixed here: a ComboBox doesn't bring an existing selection into view when its dropdown opens. That gap is already on master and is tracked in #25835; this PR adds When_ComboBox_Opened_With_Selection_ScrollIntoView, ignored until it's fixed.

PR Checklist ✅

The behavior change above is the only impact on existing apps; there is no API change.

🤖 Generated with Claude Code

Xiaoy312 and others added 3 commits October 29, 2026 07:17
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]>
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 242306 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedIconPage.png
    • AppBarToggleButtonTest.png-dark
    • ApplicationViewSizing.png
    • AppWindowFeatures.png-dark
    • AppXamlDefinedResources.png-dark
    • Arrange_Performance01.png
    • AuthenticationBroker_Cancel.png-dark
    • AutoBorderStretchwithrightmargin.png-dark
    • AutoBorderStretchwithrightmargin.png
    • AutoSizedPathCentered.png-dark
    • AutoSizedPathCentered.png
    • AutoSuggestBox_Keyboard.png-dark
    • AutoSuggestBox_Keyboard.png
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • Basics_Automated.png-dark
    • Basics_Automated.png
    • BezierSegment.png-dark
    • BezierSegment.png
  • skia-windows-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedVisualsTestbedPage.png
    • AppBarButtonWithIconTest.png
    • AppBar_KeyBoard.png
    • ApplicationViewSpanningRectsPage.png-dark
    • AppWindowClosing.png-dark
    • AppWindowFeatures.png
    • AppWindowTitleBar Properties.png-dark
    • AppWindowTitleBar Properties.png
    • Attributed_text_Simple.png-dark
    • Attributed_text_Simple.png
    • AutoBorderStretchwithbottommargin.png
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationProperties_Name.png
    • AutomationProperties_Relations.png-dark
    • AutoSuggestBox_BitmapIcon.png
    • AutoSuggestBox_Description.png-dark
    • AutoSuggestBox_Reason.png-dark
    • AutoSuggestBox_Reason.png

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]>
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 242327 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png
    • AnimatedBackVisualSourceSamplePage.png
    • AppBarButtonWithIconTest.png-dark
    • AppBarButtonTest.png-dark
    • ApplicationViewMode.png-dark
    • AppBar_KeyBoard.png-dark
    • AppWindowClosing.png-dark
    • Application_DispatcherShutdownMode.png-dark
    • AppWindowPresenters.png-dark
    • AppWindowPresenters.png
    • ArcSegment.png
    • Attributed_text_Simple.png-dark
    • AuthenticationBroker_Cancel.png
    • AuthenticationBroker_Demo.png-dark
    • AutoBorderStretchwithtopmargin.png-dark
    • AutoBorderStretchwithrightmargin.png-dark
    • AutomationProperties_Name.png
    • AutomationProperties_Landmark.png
    • AutomationProperties_Relations.png-dark
    • AutomationProperties_Name.png-dark
  • skia-windows-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedVisualsTestbedPage.png
    • AppBar_KeyBoard.png
    • ApplicationViewSizing.png
    • AppWindowClosing.png
    • AppWindowPresenters.png
    • ArcSegment.png
    • Attributed_text_Supserscript.png
    • AuthenticationBroker_Cancel.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationProperties_Landmark.png-dark
    • AutomationProperties_Landmark.png
    • AutoSuggestBox_Description.png-dark
    • AutoSuggestBox_Description.png
    • BackGesture.png-dark
    • BackGesture.png
    • Basics Pivot Test.png
    • Basics.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 242327 has failed on Uno.UI - CI.

@MartinZikmund
MartinZikmund merged commit a1428e3 into master Nov 4, 2026
52 of 54 checks passed
@MartinZikmund
MartinZikmund deleted the dev/xygu/20261029/selection-scroll-focus-gated branch November 4, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ListView scrolls to the selected item even when it doesn't have focus

4 participants