Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mousemove and preventDefault() #278

Closed
annevk opened this issue Nov 2, 2020 · 26 comments
Closed

mousemove and preventDefault() #278

annevk opened this issue Nov 2, 2020 · 26 comments

Comments

@annevk
Copy link
Member

annevk commented Nov 2, 2020

Per https://bugzilla.mozilla.org/show_bug.cgi?id=1674658 and https://jsfiddle.net/zu0jpar2/ in particular this seems like some hacky way to prevent text selection in Chrome/Safari that does not work in Firefox. The specification just says that mousemove is cancelable, but doesn't describe what that means.

@saschanaz
Copy link
Member

I feel it shouldn't be cancelable because, as a comment in the bug says, the mouse move itself can't be canceled.

@annevk
Copy link
Member Author

annevk commented Jan 13, 2021

Agreed, but that would require Chrome and Safari to change their implementation.

cc @rniwa @NavidZ

@NavidZ
Copy link
Member

NavidZ commented Jan 13, 2021

cc @mustaqahmed

@mustaqahmed
Copy link
Member

We (Chromium) attempted to fix this behavior twice already, in 2015 and 2018! Compat problems forced us to revert in both cases!!

Interestingly, Safari didn't allow canceling mousemove until 2015 (or may be later), see the bug I linked above. Curious what motivated Safari to introduce this.

@saschanaz
Copy link
Member

It seems the second revert was due to Chrome's internal use, though.

@mbrodesser
Copy link

According to the spec, a "mousemove" event has no default action. But a "mousedown" event has.
For the former to be consistent with the latter, the former should get a default action consisting of extending a possibly started selection.

That would match Chrome's and Firefox's behavior when preventDefault() is not called. Firefox would then have to follow Chrome's behavior of not extending the selection when preventDefault() was called.

AFAIK, Safari's behavior is the same as Chrome's.

moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 23, 2021
Currently, the test violates the spec. See
w3c/uievents#278. However, it's the behavior
of all major browsers and the desired one. The spec should be fixed
separately in above ticket.

Differential Revision: https://phabricator.services.mozilla.com/D106082

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1674658
gecko-commit: 580b096a83eaf535229d0d1bce67f5966570ad29
gecko-reviewers: smaug
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Feb 23, 2021
Currently, the test violates the spec. See
w3c/uievents#278. However, it's the behavior
of all major browsers and the desired one. The spec should be fixed
separately in above ticket.

Differential Revision: https://phabricator.services.mozilla.com/D106082
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 24, 2021
Currently, the test violates the spec. See
w3c/uievents#278. However, it's the behavior
of all major browsers and the desired one. The spec should be fixed
separately in above ticket.

Differential Revision: https://phabricator.services.mozilla.com/D106082

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1674658
gecko-commit: 580b096a83eaf535229d0d1bce67f5966570ad29
gecko-reviewers: smaug
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Feb 25, 2021
Currently, the test violates the spec. See
w3c/uievents#278. However, it's the behavior
of all major browsers and the desired one. The spec should be fixed
separately in above ticket.

Differential Revision: https://phabricator.services.mozilla.com/D106082

UltraBlame original commit: 580b096a83eaf535229d0d1bce67f5966570ad29
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Feb 25, 2021
Currently, the test violates the spec. See
w3c/uievents#278. However, it's the behavior
of all major browsers and the desired one. The spec should be fixed
separately in above ticket.

Differential Revision: https://phabricator.services.mozilla.com/D106082

UltraBlame original commit: 580b096a83eaf535229d0d1bce67f5966570ad29
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Feb 25, 2021
Currently, the test violates the spec. See
w3c/uievents#278. However, it's the behavior
of all major browsers and the desired one. The spec should be fixed
separately in above ticket.

Differential Revision: https://phabricator.services.mozilla.com/D106082

UltraBlame original commit: 580b096a83eaf535229d0d1bce67f5966570ad29
@saschanaz
Copy link
Member

Seems the Firefox behavior has changed to match others 🙂

@mustaqahmed
Copy link
Member

@saschanaz Your comment on Jan 13 is correct, and I convinced myself we should retry removing the mousemove default in Chrome! Do we know why Firefox decided to match Chrome???

@saschanaz
Copy link
Member

I think it was per #278 (comment). I still think it's hacky and selectionchange should be preferred instead 🤔. @mbrodesser

@mbrodesser
Copy link

mbrodesser commented Mar 11, 2021

I think it was per #278 (comment).

Yes.

I still think it's hacky and selectionchange should be preferred instead thinking. @mbrodesser

Sure, this can be changed. I agree that it would be cleaner. @rniwa: any concerns from your side?

@rniwa
Copy link

rniwa commented Mar 12, 2021

I still think it's hacky and selectionchange should be preferred instead thinking. @mbrodesser

Sure, this can be changed. I agree that it would be cleaner. @rniwa: any concerns from your side?

Change what?

@mbrodesser
Copy link

I still think it's hacky and selectionchange should be preferred instead thinking. @mbrodesser

Sure, this can be changed. I agree that it would be cleaner. @rniwa: any concerns from your side?

Change what?

What's mentioned in #278 (comment).

@rniwa
Copy link

rniwa commented Mar 12, 2021

What does "removing mousemove default" mean in this context? Making preventDefault on mousemove a no-op?

@annevk
Copy link
Member Author

annevk commented Mar 12, 2021

Yeah.

@saschanaz
Copy link
Member

We at Mozilla found that this is not web compatible since jQuery Mobile calls MouseEvent#preventDefault() on desktop browsers without expecting mousemove. We had to restore our previous behavior after getting regression reports.

We should probably prefer selectionchange event for this purpose and make mousemove not cancelable.

@justanotheranonymoususer

@saschanaz so how does it work with other browsers such as Chrome? There's probably other behavior difference of Firefox vs Chrome beyond the cancelability of mousemove?

@saschanaz
Copy link
Member

saschanaz commented Jul 27, 2021

@saschanaz so how does it work with other browsers such as Chrome? There's probably other behavior difference of Firefox vs Chrome beyond the cancelability of mousemove?

A weird bug in Chrome prevents canceling mousemove default action when CSS transform: translate() is used elsewhere on the page. So some websites basically are depending on that bug, e.g. travador.com.

@mustaqahmed
Copy link
Member

We at Mozilla found that this is not web compatible since jQuery Mobile calls MouseEvent#preventDefault() on desktop browsers without expecting mousemove. We had to restore our previous behavior after getting regression reports.

I got confused with this today after seeing that the WPT is passing in Chrome! I think this is because the test ends too early before catching the Chrome problem. Before I land the change, I wanted to double-check: @saschanaz you meant Mozilla now ignores mosuemove cancellation again, is this correct?

We should probably prefer selectionchange event for this purpose and make mousemove not cancelable.

Unfortunately, the selectionchange event is not cancelable! And I don't see any other candidate event that can possibly allow suppressing selection-extension.

@saschanaz
Copy link
Member

Weird, not sure what happened exactly, but the test suddenly started to pass around October 2022 without any implementation change nor the test change. I wonder any test harness change affected it.

@saschanaz
Copy link
Member

@jgraham might know what happened?

@jgraham
Copy link
Member

jgraham commented Dec 6, 2022

Looks like it was actually fixed in July by https://bugzilla.mozilla.org/show_bug.cgi?id=1543337

@saschanaz
Copy link
Member

That didn't touch testing/web-platform/meta/uievents/mouse/mousemove_prevent_default_action.tentative.html.ini, no?

@saschanaz
Copy link
Member

mustaqahmed referenced this issue in web-platform-tests/wpt Dec 7, 2022
A canceled mousemove should not suppress the following selectionchange
event.  The selectionchange event after mousedown is not relevant
here.

Bug: 346473
Change-Id: I48f776b68cda4b2294fdd973bf45c2e88d1d47ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4081610
Reviewed-by: Kevin Ellis <[email protected]>
Commit-Queue: Mustaq Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1079979}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 7, 2022
This is related to w3c/uievents#278.

Bug: 346473
Change-Id: I0bc9d732369a0fa5eb8f4a4bcc04c7eabce26e6b
aarongable pushed a commit to chromium/chromium that referenced this issue Dec 7, 2022
This is related to w3c/uievents#278.

Bug: 346473
Change-Id: I0bc9d732369a0fa5eb8f4a4bcc04c7eabce26e6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4086261
Reviewed-by: Kevin Ellis <[email protected]>
Commit-Queue: Mustaq Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1080459}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 7, 2022
This is related to w3c/uievents#278.

Bug: 346473
Change-Id: I0bc9d732369a0fa5eb8f4a4bcc04c7eabce26e6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4086261
Reviewed-by: Kevin Ellis <[email protected]>
Commit-Queue: Mustaq Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1080459}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 7, 2022
This is related to w3c/uievents#278.

Bug: 346473
Change-Id: I0bc9d732369a0fa5eb8f4a4bcc04c7eabce26e6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4086261
Reviewed-by: Kevin Ellis <[email protected]>
Commit-Queue: Mustaq Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1080459}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Dec 12, 2022
…move doesn't affect drag., a=testonly

Automatic update from web-platform-tests
[Interop] Add a WPT that canceling mousemove doesn't affect drag.

This is related to w3c/uievents#278.

Bug: 346473
Change-Id: I0bc9d732369a0fa5eb8f4a4bcc04c7eabce26e6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4086261
Reviewed-by: Kevin Ellis <[email protected]>
Commit-Queue: Mustaq Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1080459}

--

wpt-commits: 295326a59547f180def6ca57e5794fa68e07939f
wpt-pr: 37377
BruceDai pushed a commit to BruceDai/wpt that referenced this issue Dec 13, 2022
This is related to w3c/uievents#278.

Bug: 346473
Change-Id: I0bc9d732369a0fa5eb8f4a4bcc04c7eabce26e6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4086261
Reviewed-by: Kevin Ellis <[email protected]>
Commit-Queue: Mustaq Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1080459}
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Dec 14, 2022
…move doesn't affect drag., a=testonly

Automatic update from web-platform-tests
[Interop] Add a WPT that canceling mousemove doesn't affect drag.

This is related to w3c/uievents#278.

Bug: 346473
Change-Id: I0bc9d732369a0fa5eb8f4a4bcc04c7eabce26e6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4086261
Reviewed-by: Kevin Ellis <[email protected]>
Commit-Queue: Mustaq Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1080459}

--

wpt-commits: 295326a59547f180def6ca57e5794fa68e07939f
wpt-pr: 37377
@mustaqahmed
Copy link
Member

Looking back at this issue after a while, I get a partial picture about compat problems with two orthogonal default actions of mousemove:

We need to check each event on Chrome, Firefox and Safari for a complete picture.

@saschanaz
Copy link
Member

Just noticed @mustaqahmed's Intent to Ship: https://groups.google.com/a/chromium.org/g/blink-dev/c/fyVzOAmQHzU, I guess we can close this issue once Chrome ships it successfully.

@mustaqahmed
Copy link
Member

I agree we can close it. Chrome is shipping it on M125 (Stable to be released in ~a week), and the WPT is passing in all browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants