Skip to content

A touch swipe raises Tapped when the element moves with the finger #25731

Open

Description

@mikernet

Current behavior 🐛

A touch swipe that starts on an element raises Tapped on that element when the element moves along with the finger, however long the swipe. This happens when a parent scrolls its content by handling the manipulation events itself instead of using a ScrollViewer, or moves the element with a transform.

We hit it in a WebAssembly app with the CommunityToolkit DataGrid, which scrolls sideways by handling ManipulationDelta and moving its rows. A 200 px sideways swipe that started on a cell scrolled the grid and also raised Tapped on the cell, so the row got selected, its details opened and a flyout opened.

A ScrollViewer isn't affected: when it starts scrolling, its direct manipulation cancels the pointer for the elements under the finger, so swiping a ListView doesn't select an item.

Expected behavior 🎯

A swipe that travels past the tap distance on screen is never a tap, whether the element under the finger stays in place or moves with the finger. That's how WinUI behaves.

How to reproduce it (as minimally and precisely as possible) 🔬

<Border Width="400" Height="100" Background="Green"
        ManipulationMode="TranslateX" ManipulationDelta="OnManipulationDelta">
  <Border Width="300" HorizontalAlignment="Left" Background="Red" Tapped="OnTapped">
    <Border.RenderTransform>
      <TranslateTransform x:Name="RowTransform" />
    </Border.RenderTransform>
  </Border>
</Border>
private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
    => RowTransform.X = e.Cumulative.Translation.X;

private void OnTapped(object sender, TappedRoutedEventArgs e)
    => System.Diagnostics.Debug.WriteLine("Tapped");
  1. Touch the red border, swipe 200 px to the right and lift the finger.
  2. The red border follows the finger, and Tapped is raised when the finger lifts.
  3. Empty OnManipulationDelta, so the red border stays in place, and swipe again: Tapped isn't raised.

A runtime test with injected touch shows it on Skia Desktop (Windows), on master at b40e235:

Touch input on the red border Tapped
Tap raised
200 px swipe, the border stays in place not raised
200 px swipe, the border follows the finger raised

Workaround 🛠️

For a control you own: set a flag in the parent's ManipulationStarted, ignore Tapped while it's set, and clear it in the next PointerPressed. This doesn't help when the Tapped handler is inside a third-party control.

Affected platforms 📱💻🖥️

All platforms 🌍 (found on WebAssembly, reproduced on Desktop (Windows))

Uno.Sdk version (and other relevant versions) 📦

master at b40e235 (Uno 7.0 dev), and Uno.Sdk 6.8.0-dev.66 (Uno.WinUI 6.8.0-dev.222).

IDE version 🧑‍💻

Not IDE-related.

Anything else we need to know? 💬

A UIElement feeds its GestureRecognizer with points relative to the element itself (GetCurrentPoint(this)), and the recognizer checks the tap distance (IsOutOfTapRange) on PointerPoint.Position for taps, double-taps, holds and the start of a drag. When the element moves along with the finger, the finger barely moves relative to the element, so a long swipe still passes the check.

In WinUI, ElementGestureTracker feeds the element's recognizer with the PointerPoint of the input itself, which is relative to the root (ElementGestureTracker.cpp: it hit-tests that same position with IsPointerPositionOver). The tap args keep that global point and convert it when GetPosition is called (InputServices.cpp). So the tap distance is measured in root coordinates. Uno's own manipulation tracking already uses PointerPoint.RawPosition, which is relative to the window, to stay independent of transforms on the element.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions