Skip to content

fix: cancel parent direct manipulations after press bubble completes - #23135

Merged
ramezgerges merged 2 commits into
unoplatform:masterfrom
ramezgerges:fix/manipulation-cancelled-in-scrollviewer
May 1, 2026
Merged

ramezgerges merged 2 commits into
unoplatform:masterfrom
ramezgerges:fix/manipulation-cancelled-in-scrollviewer

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: closes https://github.com/unoplatform/kahua-private/issues/434

PR Type:

What is the current behavior? 🤔

What is the new behavior? 🚀

PR Checklist ✅

Please check if your PR fulfills the following requirements:

Other information ℹ️

Copilot AI review requested due to automatic review settings April 24, 2026 19:57
@ramezgerges
ramezgerges marked this pull request as draft April 24, 2026 19:57
@ramezgerges
ramezgerges requested a review from dr1rrb April 24, 2026 19:57

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

Adjusts managed direct-manipulation cancellation timing so parent direct manipulations (e.g., ScrollViewer) are cancelled only after the PointerPressed bubble completes, preventing premature completion/redirect during nested manipulation scenarios.

Changes:

  • Remove early CancelDirectManipulations() call from UIElement.OnPointerDown.
  • Add post-bubble cancellation in AfterPressForDirectManipulation for non-System UIElement manipulation recognizers.
  • Add a runtime test that reproduces/guards the pinch-inside-ScrollViewer regression.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Uno.UI/UI/Xaml/UIElement.Pointers.cs Stops cancelling parent direct manipulations during OnPointerDown bubbling.
src/Uno.UI/UI/Xaml/Internal/InputManager.Pointers.ManagedDirectManip.cs Cancels parent direct manipulations after press bubbling completes; exposes UIElement from UIElementRecognizer for the new logic.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.Manipulations.cs Adds regression test for pinch/scale within a ScrollViewer to ensure manipulations don’t complete mid-gesture.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

@ramezgerges
ramezgerges force-pushed the fix/manipulation-cancelled-in-scrollviewer branch from 327789e to aee5de2 Compare April 29, 2026 08:21
Copilot AI review requested due to automatic review settings April 29, 2026 08:38
@ramezgerges
ramezgerges force-pushed the fix/manipulation-cancelled-in-scrollviewer branch from aee5de2 to a2a4a9a Compare April 29, 2026 08:38
@ramezgerges
ramezgerges marked this pull request as ready for review April 29, 2026 08:40

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 adjusts Uno’s pointer/manipulation routing so that when a non-System ManipulationMode UIElement participates in a press bubble, ancestor direct manipulations (e.g., ScrollViewer/ScrollContentPresenter DM) are cancelled/avoided to prevent mid-gesture pointer hijacking (notably during pinch/scale inside scrollable content).

Changes:

  • Cancel ancestor direct manipulations on UIElement.OnPointerDown when ManipulationMode is non-System.
  • Prevent registering a parent direct manipulation handler if an in-bubble UIElement recognizer should block it (new BlocksDirectManipulationFor hook).
  • Add a runtime regression test covering pinch/scale inside a ScrollViewer to ensure ManipulationCompleted doesn’t fire mid-gesture and ManipulationDelta continues through the gesture.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/Uno.UI/UI/Xaml/UIElement.Pointers.cs Cancels parent direct manipulations on pointer down for non-System manipulation elements.
src/Uno.UI/UI/Xaml/Internal/InputManager.Pointers.ManagedDirectManip.cs Adds blocking check to avoid creating ancestor direct manipulations when a descendant manipulation recognizer has claimed the gesture.
src/Uno.UI/UI/Xaml/Internal/DirectManipulation.cs Implements the new interface method (BlocksDirectManipulationFor) for direct manipulation recognizers (no blocking).
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.Manipulations.cs Adds an input-injection regression test reproducing and guarding the pinch-vs-scroll DM interaction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

…settles

When a UIElement has ManipulationMode != System it has already declared "I'm
handling this manipulation"; UIElement.OnPointerDown calls
CancelDirectManipulations() to drop ancestor DMs. That call walks the DM list
at the moment OnPointerDown runs — which during managed bubbling
(ctx=OnManagedBubbling) is BEFORE higher ancestors like ScrollContentPresenter
have had a chance to register their DMs via TryEnableDirectManipulation. The
later-registered ancestor DM survives, tracks the pointer, and on the next
move fires OnDirectManipulationStarted → CancelPointer, aborting the
descendant's manipulation. On Skia Android, a pinch on a ManipulationMode=Scale
Grid inside a scrollable ScrollViewer would fire ManipulationCompleted
mid-gesture for exactly this reason.

Track the first requester in InputManager.PointerManager.CancelDirectManipulations
in a per-press field, reset in BeforePressTryRedirectToManipulations and
consumed in AfterPressForDirectManipulation by re-running the cancel walk for
that element. Because everything goes through
InputManager.PointerManager.CancelDirectManipulations, this also covers
end-user calls to UIElement.CancelDirectManipulations(): if app code cancels
DMs from a custom PointerPressed handler before the bubble has reached the
ScrollContentPresenter, the after-bubble redo catches the late registration.
@ramezgerges
ramezgerges force-pushed the fix/manipulation-cancelled-in-scrollviewer branch from a2a4a9a to 567b140 Compare April 30, 2026 17:08
@unodevops

Copy link
Copy Markdown
Contributor

Add When_PinchOnScaleGrid_InsideScrollViewer_Then_ManipulationDoesNotCompletePrematurely.
Reproduces the prior bug where a two-finger pinch on a ManipulationMode=Scale
Grid inside a scrollable ScrollViewer would fire ManipulationCompleted
mid-gesture because ScrollContentPresenter's DirectManipulation stole the
second pointer.

Two requirements to actually trigger the bug:

 * Content must be bigger than the viewport (600x600 Grid inside a 300x300
   ScrollViewer) so the SCP DM doesn't abort immediately for lack of
   scrollable space.
 * The pressed element must be a child of the Scale grid (a 300x300 Rectangle
   pinned to the top-left) so the grid is an intermediate element in the
   bubble — the managed-bubbling path which ran the broken cancel timing.

Fingers fan outward with asymmetric Y drift so the SCP DM's TranslateY
threshold (15 px on touch) is crossed partway through, exactly matching the
device-level repro.
Copilot AI review requested due to automatic review settings April 30, 2026 18:12
@ramezgerges
ramezgerges force-pushed the fix/manipulation-cancelled-in-scrollviewer branch from 567b140 to f347111 Compare April 30, 2026 18:12

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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

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

@ramezgerges
ramezgerges enabled auto-merge May 1, 2026 15:01
@ramezgerges
ramezgerges merged commit 178f4a2 into unoplatform:master May 1, 2026
49 checks passed
@ramezgerges
ramezgerges deleted the fix/manipulation-cancelled-in-scrollviewer branch May 7, 2026 22:12
@agneszitte

Copy link
Copy Markdown
Member

@Mergifyio backport release/stable/6.6

@mergify

mergify Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.6

✅ Backports have been created

Details

agneszitte added a commit that referenced this pull request Jun 1, 2026
…6.6/pr-23135

fix: cancel parent direct manipulations after press bubble completes (backport #23135)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants