Open Bug 1534668 Opened 6 years ago Updated 2 years ago

Windows 10 - Precision Touchpad - Unable to prevent scrolling DOMMouseScroll

Categories

(Core :: DOM: Events, defect, P3)

Desktop
Windows 10
defect

Tracking

()

Tracking Status
firefox66 --- affected
firefox67 --- affected

People

(Reporter: roland, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36

Steps to reproduce:

  1. On Windows 10 with Precision Touchpad (Virtual touchpad works fine) open: https://jsfiddle.net/wutx16o4/
  2. Scroll the red area with 2 finger scroll on the touchpad

Actual results:

The page scrolls away.

Expected results:

It shouldn't scroll away as the event has .preventDefault(); call:

document.getElementById('div1').addEventListener('DOMMouseScroll', function(e){
e.preventDefault();
});

Hi @roland, I cannot see any differences between Firefox & Chrome, on both sides there are the same result. Please try in Firefox with Add-ons disabled and then test in other browsers (e.g. Chrome) and let me know the results. Thanks.

Flags: needinfo?(roland)

Thanks for the reply. I see what I did there. In my original code I used 'DOMMouseScroll' event for Firefox and 'mousewheel' event for Chrome.

Now I started to use the 'wheel' event and if I use this, I'm able to prevent the scroll on 2 finger touchpad drag.
But Firefox dispatch for this interaction 'DOMMouseScroll' events and while this event comes from a real mouse, I can prevent the scroll just fine. But if this event comes from the touchpad, then I'm unable to prevent the scroll.

So if you check this example: https://jsfiddle.net/v0xhzt3q/1/
Chrome will prevent the scroll while Firefox will allow scroll.

And this example with 'wheel' event will work fine in Firefox too:
https://jsfiddle.net/v0xhzt3q/2/

Flags: needinfo?(roland) → needinfo?(liviu.seplecan)

Hi @roland, I've re-tested the issue.
[Firefox version affected]: latest nightly 68.0a1, beta 66, release 65.0.2 - on all versions the example https://jsfiddle.net/v0xhzt3q/1/ - cannot prevent scroll. In the 2nd example: https://jsfiddle.net/v0xhzt3q/2/ - the scroll works accordingly.

Additionally, both examples ('DOMMouseScroll' / 'wheel') can prevent scroll if there are rendered in other browser e.g Chrome.
I will set a component and if this isn't an appropriate one someone from dev's team could change it.

Status: UNCONFIRMED → NEW
Component: Untriaged → DOM: Events
Ever confirmed: true
Flags: needinfo?(liviu.seplecan)
OS: Unspecified → Windows 10
Product: Firefox → Core
Hardware: Unspecified → Desktop
Version: 65 Branch → Trunk

I can't reproduce the issue on linux. Will test Win10 later.

Masayuki, does this ring any bells?

Flags: needinfo?(masayuki)
Priority: -- → P3

https://searchfox.org/mozilla-central/rev/7abb9117c8500ed20833746c9f8e800fce3a4688/dom/events/EventListenerManager.cpp#1692-1697 treats the events the same way.

But, is this about MozMousePixelScroll event? I guess this laptop doesn't end up dispatching those.
wheel event is of course the one one should always use.

roland, if you try preventDefault() on MozMousePixelScroll too, does it help?
(but, as I said, wheel event is the one to use, that is the only one defined in a specification. mousewheel and DOMMouseScroll and MozMousePixelScroll are legacy events, and shouldn't be used.)

Flags: needinfo?(roland)

The result with MozMousePixelScroll is the same with DOMMouseScroll. I was able to scroll down. https://jsfiddle.net/zod5fvje/

Ps.: I know these are legacy event, but they might indicate underlying issues.

Flags: needinfo?(roland) → needinfo?(bugs)

Please also note that only Windows 10 Precision Touchpad affected (or touchscreen with Virtual Touchpad).

With MozMousePixelScroll, I see the expected result (comment 7). And I confirmed the comment 0 case won't work as expected (i.e., scrolled smoothly).

Only with DOMouseScroll, you cannot prevent scroll unfortunately because only MozMousePixelScroll and wheel events are dispatched in most cases if you use high-resolution wheel. Only when accumulated scroll amount reaches 1 or -1 line, DOMMouseScroll event is also fired, therefore, it looks like that preventing the default of DOMMouseScroll does nothing because for example, the default of one of 100 wheel events is prevented.

(Note that I'm struggling with this compatibility issue in bug 1406243, but I've not found a smart way yet.)

Flags: needinfo?(masayuki)
Severity: normal → S3
Flags: needinfo?(bugs)

I think this should be fixed now that we use dmanip with precision touchpads. Could you check if it's working for you now?

Flags: needinfo?(roland)

I tried it in Firefox 90 and this issue solved.

Flags: needinfo?(roland)
See Also: → 1705584
You need to log in before you can comment on or make changes to this bug.