Skip to content

feat: Add opt-in press-to-stop-momentum for ManipulationMode panning (backport #24282) - #24501

Merged
agneszitte merged 10 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24282
Sep 11, 2026
Merged

agneszitte merged 10 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24282

Conversation

@mergify

@mergify mergify Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: Tracked internally (customer-reported). No public issue.

PR Type:

✨ Feature

What changed? 🚀

A customer reported that on a tablet, tapping a CommunityToolkit DataGrid while it is still decelerating after a fling both stops the momentum and selects the row under the finger, instead of the first tap only halting the scroll.

This turned out to be intended WinUI behaviour, not a bug. The DataGrid pans its rows through the ManipulationMode of its DataGridRowsPresenter (runtime-confirmed: TranslateX, TranslateY, TranslateRailsX, TranslateRailsY, TranslateInertia, System), and in WinUI gesture recognition for that path is per-element and independent of an ancestor's inertia:

  • interaction contexts are keyed per CUIElement (CInteractionManager::m_mapInteractions), so a descendant's tap recognition knows nothing about the panning ancestor's inertia;
  • CInteractionManager::IsManipulationInertiaProcessing() has zero callers, so nothing gates press dispatch while an inertia is running;
  • the tap-suppression guard that does exist — GestureOutputMapper::OnTapped/OnSecondaryTapped/OnHolding dropping the message when IsInteractionStopping() && IsInteractionStopped() — is armed only by ElementGestureTracker::Stop(), whose callers are DirectManipulation-steals-the-pointer, capture-changed and focus. Not "a press landed during my own inertia".

So WinUI activates the pointed item on that press, and Uno Platform now keeps doing the same by default.

Worth noting the corollary: Uno Platform's own ScrollViewer is not diverging. Its touch panning goes through the direct-manipulation pipeline, which swallows the press that stops an inertia before it reaches the visual tree — the same thing DirectManipulation does on WinUI. Only the UIElement.ManipulationMode path is affected, which is why the two behave differently today.

The gap is nonetheless real on touch-only targets: a browser on a tablet has no mouse, and users expect the OS convention that the first press only stops the momentum. That makes this an enhancement, which must not change default behaviour on any target.

So it ships as an opt-in Toolkit extension:

<Border ManipulationMode="TranslateY,TranslateInertia"
        toolkit:ManipulationExtensions.IsTapToStopInertiaEnabled="True">

While enabled, the press that aborts the inertia raises no Tapped, DoubleTapped, RightTapped or Holding on the element, its ancestors or its descendants; a tap at rest is unaffected. It is a no-op on Windows.

Applied through an implicit Style it also reaches panning elements an app cannot address directly — including DataGrid's DataGridRowsPresenter, which is the customer's actual case:

<Style TargetType="primitives:DataGridRowsPresenter">
    <Setter Property="toolkit:ManipulationExtensions.IsTapToStopInertiaEnabled" Value="True" />
</Style>

This does change core code, and the default is unchanged

The Toolkit cannot observe what it needs on its own, so Uno.UI gains four internals. All of them are purely additive and behaviour-neutral — nothing in core reads them, so no code path changes unless the opt-in is set. Core reports the fact, the opt-in decides what to do with it:

  • GestureRecognizer.Manipulation.IsCoasting
  • GestureRecognizer.LastDownStoppedInertia — informative only; the gestures of that press are still recognized exactly as before
  • UIElement.LastPointerDownStoppedInertia
  • UIElement.PreventGestures(pointer, gestures)

GestureRecognizer.ProcessDownEvent gains one assignment to compute the flag; every other line is a new member. The unchanged default is pinned by When_PressStopsInertia_Without_OptIn_Then_TapIsRaised.

Platform reach

The opt-in is honoured on the targets which use the managed pointer pipeline — every Skia target (Desktop, and Skia on Android, iOS and WebAssembly) and the WebAssembly backend. It is inert on WinAppSDK, where the callback body is #if HAS_UNO so the property just stores its value and cross-platform XAML stays valid. On the native Android and iOS backends pointer events bubble natively, so the order the gestures are muted in has not been validated and those backends are documented as unsupported for this opt-in.

The property is deliberately not gated per target: the default is unchanged unless it is set, and a setter that silently refuses a value is harder to diagnose than one documented as inert.

Implementation note

The muting needs two passes because of the order in which a press reaches the gesture recognizers: each element updates its own gestures before invoking its handlers, ancestors are visited from the closest to the root, and the original source updates its own gestures last of all. So the extension mutes the original-source→tracked-element path on the press (retroactively, those gestures already exist) and the remainder — the ancestors and the original source — on the release, which still runs before their gestures are recognized.

Validation

  • Runtime — Skia Desktop (SamplesApp.Skia.Generic), Given_ManipulationExtensions: 3 passed.
    • When_PressStopsInertia_Without_OptIn_Then_TapIsRaised pins the default, i.e. the WinUI behaviour, so parity cannot regress silently.
    • When_PressStopsInertia_With_OptIn_Then_NoTapIsRaisedOnThePath asserts no tap on the original source, an intermediate element, the coasting element and an ancestor — the four positions the two passes have to cover.
    • When_TapAtRest_With_OptIn_Then_TapIsRaisedOnThePath asserts the opt-in leaves a normal tap alone.
    • Both halves of the muting are load-bearing: removing the retroactive pass fails on the intermediate element, removing the forward flag fails on the original source.
  • Runtime (regression) — 92 passed / 13 skipped across Given_InputManager, Given_GestureRecognizer, Given_ScrollViewer, Given_SwipeControl, Given_FlipView, Given_RefreshContainer and Uno_UI_Toolkit.
  • Unit — Given_GestureRecognizer: the recognizer reports LastDownStoppedInertia for the aborting press and still raises the tap, plus a no-false-positive case.
  • Against the customer's repro — a rebuilt copy of the reported project (real DataGrid 7.1.205) on Skia macOS confirmed the implicit Style does deliver an attached property to DataGridRowsPresenter, and that its ManipulationMode is the inertia-enabled one above.
  • Compile — Uno.UI and Uno.UI.Toolkit for Skia, Reference, WebAssembly and iOS, and an analyzer-enabled build (no UnoFastDevBuild) of Uno.UI.Toolkit and Uno.UI.RuntimeTests: 0 errors, no new warnings.
  • Device — confirmed on iPadOS against a LAN-served WebAssembly Skia SamplesApp build of this branch, through the Manipulation_TapStopsInertia sample (its in-app toggle flips between the default and the opt-in on the same screen).

PR Checklist ✅


This is an automatic backport of pull request #24282 done by [Mergify](https://mergify.com).

@github-actions github-actions Bot added area/automation Categorizes an issue or PR as relevant to project automation kind/documentation labels Sep 11, 2026
@agneszitte
agneszitte merged commit e13ef34 into release/stable/6.7 Sep 11, 2026
19 of 31 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.7/pr-24282 branch September 11, 2026 04:08
@unodevops

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants