Skip to content

fix(skia): Allow scrolling a touch-focused TextBox away - #24099

Closed
ajpinedam wants to merge 2 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/textbox-scroll-away
Closed

ajpinedam wants to merge 2 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/textbox-scroll-away

Conversation

@ajpinedam

Copy link
Copy Markdown
Contributor

GitHub Issue: tracked internally (customer report)

PR Type:

🐞 Bugfix

What changed? 🚀

On Skia targets, once a TextBox was focused via touch (insertion handle or selection grippers showing), the parent ScrollViewer refused to let the user scroll it out of view: any scroll away from the field stopped and animated back until the TextBox was in the viewport again. On a form with many fields (customer repro), selecting text in a field near the bottom made it impossible to scroll back up.

This "keep the touch TextBox in view" clamp (ScrollViewer.ShouldSnapToTouchTextBox / ClampOffsetsToFocusedTextBox, introduced in #20155) existed to work around the selection grippers floating over unrelated content (e.g. the OS navigation bar) when their anchor was scrolled out of view, since the gripper popups were only culled against the TextBox's own (unclipped) bounds.

This PR fixes the root cause of that original artifact and removes the clamp, restoring native/WinUI scrolling parity:

  • GripperClipBounds (TextBox + selectable TextBlock) now returns the control's effective visible bounds (GetGlobalBoundsWithOptions, ancestor clips + window viewport applied) instead of its unclipped absolute bounds, so grippers are culled as soon as their anchor leaves a parent ScrollViewer's viewport (or the window) — they no longer float over unrelated content.
  • A culled gripper is now soft-hidden (child collapsed, popup kept open) so the per-frame reposition callback stays subscribed and the gripper reappears when the anchor is scrolled back into view — matching native Android/iOS handle behavior.
  • Removed ShouldSnapToTouchTextBox / ClampOffsetsToFocusedTextBox and their call sites (snap-points adjustment, snap timer arming, direct-manipulation inertia handling). The user can now freely scroll a focused touch TextBox out of view.

When_Touch_Focused_Then_Scrolled_Away was updated to assert the new expectations (scroll offset preserved, grippers culled while out of view, grippers re-shown when brought back), and a new When_Touch_TextBox_In_ScrollViewer_Scroll_Away_Does_Not_Snap_Back test covers the customer scenario (Android touch convention, insertion-handle and selection variants).

Note: when the selection toolbar (TextCommandBarFlyout) is open, the first swipe is still consumed by its light-dismiss layer (dismisses the toolbar without scrolling); WinUI's transient flyouts pass that input through. That is a separate popup-infrastructure gap, out of scope here.

PR Checklist ✅

Copilot AI lite review requested due to automatic review settings August 18, 2026 07:01
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Aug 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores Skia scrolling parity by removing the “snap back to touch-focused TextBox” clamping behavior in ScrollViewer, and instead fixing the underlying cause of selection grippers floating over unrelated content when their anchor is scrolled out of view (by culling grippers against effective visible bounds and keeping their position updates active).

Changes:

  • Update TextBox/selectable TextBlock gripper culling to use effective visible bounds (GetGlobalBoundsWithOptions with clipping applied).
  • Keep grippers tracking their anchors via a CompositionTarget.FrameRendered subscription so culled grippers can reappear when scrolled back into view.
  • Remove Skia-specific ScrollViewer clamp/snap-to-touch-textbox logic and update/add Skia runtime tests to validate the new behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs Uses clipped global bounds for gripper culling on Skia.
src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.skia.cs Uses clipped global bounds for gripper culling on Skia selectable TextBlock.
src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.SnapPoints.cs Removes Skia clamp call and ShouldSnapToTouchTextBox partial.
src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.skia.cs Removes Skia-only clamp/snap implementation.
src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs Stops arming snap-point tracking based on touch TextBox focus.
src/Uno.UI/UI/Xaml/Controls/ScrollContentPresenter/ScrollContentPresenter.Managed.cs Removes inertia snapping behavior that was solely for the touch TextBox clamp.
src/Uno.UI/UI/Xaml/Controls/Primitives/TextSelectionGripperPresenter.skia.cs Drives grippers via per-frame updates for correct repositioning/culling while scrolling.
src/Uno.UI/UI/Xaml/Controls/Primitives/CaretWithStemAndThumb.skia.cs Simplifies gripper popup lifecycle; adds test hook for popup open state.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs Updates existing test expectations and adds coverage for “scroll away does not snap back”.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +99 to +103
// Subscribed while the grippers are active (GripperMode != Hidden) so they keep tracking their
// anchors every rendered frame (scrolling, text moves), even while culled out of view or after
// their popup was closed externally. Same pattern as SystemFocusVisual.
private CompositionTarget _frameRenderedTarget;

return;
}

EnsureFrameRenderedSubscription();
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 228335 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ImageIconPage.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • DisplayInformation.png-dark
    • ContextRequested.png-dark
    • ContextRequested.png
    • Focus_FocusVisual_Properties.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
  • skia-windows-screenshots: 2348 changed over 2396

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppWindowFeatures.png
    • AnimatedIconPage.png
    • AppBarButtonTest.png-dark
    • ArcSegment.png
    • AppBarToggleButtonTest.png
    • ApplicationViewMode.png
    • AutoBorderStretchwithbottommargin.png-dark
    • AppWindowClosing.png
    • AppWindowPresenters.png
    • AutoBorderStretchwithrightmargin.png
    • Arrange_Performance01.png-dark
    • AuthenticationBroker_Demo.png-dark
    • AutomationProperties_AutomationId.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutomationPropertiesExtensions_Role.png-dark
    • AutoSuggestBox_Description.png-dark
    • AutomationProperties_AutomationId.png
    • AutoSizedTopLeft.png
    • AutoSuggestBox_Reason.png
    • AutoSuggestBox_BitmapIcon.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Uno_Web.Http.CookieManagerTests
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming

@ajpinedam
ajpinedam marked this pull request as draft August 18, 2026 13:47
@ajpinedam ajpinedam closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants