preventDefault on body mousemove doesn't work
Categories
(Core :: DOM: Selection, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox88 | --- | fixed |
People
(Reporter: mailnew4ster+github, Unassigned)
References
Details
(Keywords: parity-chrome)
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36 Edg/86.0.622.43
Steps to reproduce:
Used the following code:
JSFiddle: https://jsfiddle.net/zu0jpar2/
$('body').on('mousemove', function (event) {
event.preventDefault();
});
Actual results:
Mouse move operations are not prevented.
Expected results:
Mouse move should be prevented like in Chrome.
Updated•4 years ago
|
Comment 1•4 years ago
|
||
I wonder what Chrome actually prevents from happening there as the mouse certainly still moves (and with tricks you can still select text).
Updated•4 years ago
|
Reporter | ||
Comment 2•4 years ago
|
||
For me the issue was with code implementing drag and drop, and while dragging, in Firefox there's weird stuff such as random text selected on the page. Doesn't happen in Chrome.
I assume the tricks you're referring to is when the mouse is outside of <body>
.
Comment 3•4 years ago
|
||
I guess this is more about selection.
Could we possibly check the value of aEventStatus around here
https://searchfox.org/mozilla-central/rev/50215d649d4854812837f1343e8f47bd998dacb5/layout/generic/nsIFrame.cpp#4931
mirko, would you have time to look at this. This could be a really small change :)
Updated•4 years ago
|
I'll take a look at this once the other bugs I'm currently working are fixed. Could take a few days though. Will keep the ni?-request.
(In reply to mailnew4ster from comment #2)
For me the issue was with code implementing drag and drop, and while dragging, in Firefox there's weird stuff such as random text selected on the page. Doesn't happen in Chrome.
I assume the tricks you're referring to is when the mouse is outside of
<body>
.
This issue has been discussed at https://bugs.chromium.org/p/chromium/issues/detail?id=346473 already a longer time ago.
@mailnew4ster: does the idea presented at https://bugs.chromium.org/p/chromium/issues/detail?id=346473#c4 fix your specific issue?
See also https://w3c.github.io/uievents/#event-type-mousedown.
Firefox could follow Chrome's behavior, but it would violate the spec. So in any case, the spec should be updated. I'll try a fix at the code which :smaug mentioned in #c3.
Reporter | ||
Comment 6•3 years ago
|
||
@mbrodesser I don't think so. My code is like the following:
https://jsfiddle.net/u4q6wbpg/
Here's what happens with Firefox:
https://i.imgur.com/MaEcqhc.mp4
How can I apply your quoted suggestion to fix this?
(In reply to mailnew4ster from comment #6)
@mbrodesser I don't think so. My code is like the following:
https://jsfiddle.net/u4q6wbpg/Here's what happens with Firefox:
https://i.imgur.com/MaEcqhc.mp4How can I apply your quoted suggestion to fix this?
Try changing the event listener for "mousedown" to:
div.addEventListener('mousedown', function(e) {
isDown = true;
offset = [
div.offsetLeft - e.clientX,
div.offsetTop - e.clientY
];
e.preventDefault();
}, true);
Then, event.preventDefault()
in mousemove
becomes superfluous.
Reporter | ||
Comment 8•3 years ago
|
||
OK, now I understand what that guy meant. Yep, looks like that works, thanks.
Currently, the test violates the spec. See
https://github.com/w3c/uievents/issues/278. However, it's the behavior
of all major browsers and the desired one. The spec should be fixed
separately in above ticket.
Depends on D106082
Comment 11•3 years ago
|
||
Pushed by mbrodesser@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/580b096a83ea part 1) Add WPT. r=smaug https://hg.mozilla.org/integration/autoland/rev/697bd822d1ee part 2) Don't peform the default action for `mousemove` events when it should be prevented. r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/27741 for changes under testing/web-platform/tests
Comment 13•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/580b096a83ea
https://hg.mozilla.org/mozilla-central/rev/697bd822d1ee
Upstream PR merged by moz-wptsync-bot
Comment 15•3 years ago
|
||
Reverted by bug 1712339.
Description
•