Bug 184251 - touchmove bound to the document during a touchstart listener is not cancelable (default cannot be prevented)
Summary: touchmove bound to the document during a touchstart listener is not cancelabl...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: Safari 11
Hardware: iPhone / iPad iOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-04-02 17:48 PDT by Anand Thakker
Modified: 2023-05-04 13:30 PDT (History)
17 users (show)

See Also:


Attachments
Testcase (from GitHub with DOCTYPE) (2.47 KB, text/html)
2022-09-12 14:51 PDT, Ahmad Saleem
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anand Thakker 2018-04-02 17:48:24 PDT
Tested on: iOS 11.2.6, 11.3

Steps to reproduce:
1. Create a script that:
 - Adds a `touchstart` listener, `onStart`, to some div `myDiv`.
 - In `onStart`, add a `touchmove` listener, `onMove`, (with `{passive: false}`) to `document`.
 - In `onMove(e)`, call `e.preventDefault()`.
2. Load the page in iOS 11.2.6 or 11.3 and attempt a scroll from within `myDiv`.

Expected result: the page does not scroll.
Actual result: the page scrolls.

Self-contained example: https://gist.github.com/anandthakker/2d0e71924285a845f0c4e6c5fd966234
Comment 1 Anand Thakker 2018-04-02 17:59:07 PDT
It's worth noting that this issue arises amidst an attempt to mitigate the breaking change discussed in https://bugs.webkit.org/show_bug.cgi?id=182521.
Comment 2 Radar WebKit Bug Importer 2018-04-03 10:26:59 PDT
<rdar://problem/39145024>
Comment 3 Toby Rahilly 2018-07-18 23:43:27 PDT
Experiencing the same issue on iOS 11.4.1

Full user agent: Mozilla/5.0 (iPad; CPU OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1

Two workarounds:

1) Register a passive event listener on any non-window/document/body element that the event will bubble though.
2) Register the touchmove event listener outside of the touchstart.
Comment 4 Simon Fraser (smfr) 2018-07-19 08:40:04 PDT
3) register the listener with { passive: false }
Comment 5 Toby Rahilly 2018-07-19 08:44:41 PDT
Hi Simon, the touchmove listener is registered with { passive: false } but unfortunately still experiences the behaviour described in this bug.
Comment 6 Toby Rahilly 2018-07-19 18:10:39 PDT
I also tried registering the touchstart event with {passive: false}, but it didn't fix the problem.
Comment 7 Lucas Forschler 2019-02-06 09:19:11 PST
Mass move bugs into the DOM component.
Comment 8 Ahmad Saleem 2022-09-12 14:51:13 PDT
Created attachment 462297 [details]
Testcase (from GitHub with DOCTYPE)
Comment 9 Ahmad Saleem 2022-09-12 14:53:15 PDT
I am not able to reproduce this bug in Safari 16 on iPhone 13 Pro Max (iOS 16) and not able to scroll the page from the body in light green hue area.

Appreciate if someone else can confirm as well because I am not too sure on my testing with this test case. Thanks!
Comment 10 David 2023-05-04 12:55:21 PDT
Experiencing the same problem on iOS 16.4.1.

If I try to scroll the page on the light green area, the page scrolls but only sometimes. It’s inconsistent in other words.

The easiest way for me to reproduce the bug was to repeatedly do swipe gestures in one direction inside the green area. Eventually, one of the swipe gestures will scroll the page even though it shouldn’t.