unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.03k stars 733 forks source link

[wasm] Drag gestures starting from above/with existing selection are not captured correctly #18854

Open Xiaoy312 opened 2 days ago

Xiaoy312 commented 2 days ago

Current behavior

On WebAssembly, when there is selection underneath or around a control that typically uses drag gesture (eg: ScrollBar or Slider), the drag gesture will only work for the 1st frame/tick/delta, subsequent pointer capture events are lost, and there is an undesired browser dragging preview following the cursor: wasm selection drag

Expected behavior

^ probably shouldn't happen? at least, there should be an easy way to disable this behavior, whether this would be disabled by default is subject of discussion

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

<StackPanel Spacing="16">
    <TextBlock Text="selectable text: // select from here" IsTextSelectionEnabled="True" />

    <!-- some controls that typically use drag gestures -->
    <Slider />
    <ScrollBar Orientation="Horizontal" IndicatorMode="MouseIndicator" />

    <TextBlock Text="selectable text: // to there"  IsTextSelectionEnabled="True" />
</StackPanel>

Workaround

from the javascript side, call e.preventDefault() in the pointerdown event handler of any impacted control

just run this command from the dev console of the browser:

document
    .querySelector('[xamltype$=ContentControl]')
    .querySelectorAll('[xamltype$=ScrollBar], [xamltype$=Slider]')
    .forEach(x => x.addEventListener('pointerdown', e => e.preventDefault()))

Works on UWP/WinUI

No

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

Uno.WinUI@5.5.37

Affected platforms

WebAssembly

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

dr1rrb commented 1 day ago

Unable to repro neither on FF nor Edge on my side

FF : 132.0 (64 bits) Edge : Version 131.0.2903.51 (Version officielle) (64 bits)

dr1rrb commented 1 day ago

Humm, actually able to repro ... but on edge only!