Repository navigation
feat: Add opt-in press-to-stop-momentum for ManipulationMode panning (backport #24282) - #24501
Merged
agneszitte merged 10 commits intoSep 11, 2026
Merged
Conversation
(cherry picked from commit 825caa4)
(cherry picked from commit 2904d8a)
(cherry picked from commit 24a6e44)
(cherry picked from commit db7a6be)
(cherry picked from commit aeb4b9c)
(cherry picked from commit 3bc21e5)
(cherry picked from commit 815cab3)
(cherry picked from commit 8342b7c)
(cherry picked from commit 40e19e8)
(cherry picked from commit b844b06)
3 of 5 tasks
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24501/wasm-skia-net9/index.html |
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: Tracked internally (customer-reported). No public issue.
PR Type:
✨ Feature
What changed? 🚀
A customer reported that on a tablet, tapping a CommunityToolkit
DataGridwhile 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
DataGridpans its rows through theManipulationModeof itsDataGridRowsPresenter(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: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;GestureOutputMapper::OnTapped/OnSecondaryTapped/OnHoldingdropping the message whenIsInteractionStopping() && IsInteractionStopped()— is armed only byElementGestureTracker::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
ScrollVieweris 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 theUIElement.ManipulationModepath 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:
While enabled, the press that aborts the inertia raises no
Tapped,DoubleTapped,RightTappedorHoldingon the element, its ancestors or its descendants; a tap at rest is unaffected. It is a no-op on Windows.Applied through an implicit
Styleit also reaches panning elements an app cannot address directly — includingDataGrid'sDataGridRowsPresenter, which is the customer's actual case:This does change core code, and the default is unchanged
The Toolkit cannot observe what it needs on its own, so
Uno.UIgains 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.IsCoastingGestureRecognizer.LastDownStoppedInertia— informative only; the gestures of that press are still recognized exactly as beforeUIElement.LastPointerDownStoppedInertiaUIElement.PreventGestures(pointer, gestures)GestureRecognizer.ProcessDownEventgains one assignment to compute the flag; every other line is a new member. The unchanged default is pinned byWhen_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_UNOso 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
SamplesApp.Skia.Generic),Given_ManipulationExtensions: 3 passed.When_PressStopsInertia_Without_OptIn_Then_TapIsRaisedpins the default, i.e. the WinUI behaviour, so parity cannot regress silently.When_PressStopsInertia_With_OptIn_Then_NoTapIsRaisedOnThePathasserts 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_TapIsRaisedOnThePathasserts the opt-in leaves a normal tap alone.Given_InputManager,Given_GestureRecognizer,Given_ScrollViewer,Given_SwipeControl,Given_FlipView,Given_RefreshContainerandUno_UI_Toolkit.Given_GestureRecognizer: the recognizer reportsLastDownStoppedInertiafor the aborting press and still raises the tap, plus a no-false-positive case.DataGrid7.1.205) on Skia macOS confirmed the implicitStyledoes deliver an attached property toDataGridRowsPresenter, and that itsManipulationModeis the inertia-enabled one above.Uno.UIandUno.UI.Toolkitfor Skia, Reference, WebAssembly and iOS, and an analyzer-enabled build (noUnoFastDevBuild) ofUno.UI.ToolkitandUno.UI.RuntimeTests: 0 errors, no new warnings.Manipulation_TapStopsInertiasample (its in-app toggle flips between the default and the opt-in on the same screen).PR Checklist ✅
Screenshots Compare Test Runresults.This is an automatic backport of pull request #24282 done by [Mergify](https://mergify.com).