Click fired on wrong element in touch compared to mouse
Categories
(Core :: DOM: UI Events & Focus Handling, defect, P3)
Tracking
()
People
(Reporter: rsnow, Unassigned)
References
(Blocks 1 open bug)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36
Steps to reproduce:
https://i1hjf.csb.app/ (source here: https://codesandbox.io/s/inspiring-lehmann-i1hjf)
(1) Open developer console
(2) Enter responsive mode and turn on Touch Simulation
(3) Click BtnOne
Actual results:
click is fired on BtnTwo
Events:
btn1 pointerup
btn2 clicked
Expected results:
That click is fired on BtnOne and no mouse/pointer/touch/click events are fire on BtnTwo
btn1 pointerup
btn1 clicked
Here's an example with a link as well https://codesandbox.io/s/trusting-poitras-u89ub?file=/index.html
Use case for this being that you have a menu that opens over the button or link, upon selection, the menu disappears, and click is fired on the item underneath.
Comment 2•4 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'DevTools::Responsive Design Mode' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Updated•4 years ago
|
Comment 3•4 years ago
|
||
Hello rsnow,
So I connected to Firefox on Android with your test page (thanks for putting up one, that's very helpful), and I'm getting the same behavior than with RDM and touch simulation.
I also tested in Chrome and I'm getting the same events on the same elements than with Firefox.
So I'd say that's the expected behavior here and I'm going to close this bug.
In order to fix this, I guess you want to add button two not on pointerup
, but on click
?
Hey, thanks for taking a look. I found the same thing in Chrome first actually and have a bug logged against them as well https://bugs.chromium.org/p/chromium/issues/detail?id=1150073
Please see a comment from smugmug in that thread. It's not just responsive mode, it's on real devices as well and shows a difference between mouse and touch behaviors.
Comment 5•4 years ago
|
||
I logged mousedown/mouseup/click/pointerdown/pointerup events.
With a real mouse, the sequence is:
- pointerdown
- mousedown
- pointerup
- mouseup
- click
With a real touch device, the sequence is:
- pointerdown
- pointerup
- mousedown
- mouseup
- click
On a test page such as https://i1hjf.csb.app/ , which replaces the "clicked" element on pointerup, I can see why the discrepancy between the two sequences yields different results.
I can't tell if the behavior is correct or not, but I guess it makes writing code for touch events difficult if you need to constantly test against mouse devices vs touch devices.
Moving to Core.
Updated•4 years ago
|
Description
•