Open Bug 1647711 Opened 5 years ago Updated 5 years ago

mousedown/mouseup preventDefault() doesn't block click

Categories

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

77 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: ossman, Unassigned)

Details

Attachments

(1 file)

Attached file contextmenu.html

User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0

Steps to reproduce:

  1. Add event listener for mouseup and mousedown
  2. Call preventDefault() in event handler

Actual results:

Got a click event after the mousedown and mouseup events.

Expected results:

Should only have gotten the mousedown and mouseup events.

See also bug 186356. Attached test case covers both issues.

Also buggy on Chrome:

https://bugs.chromium.org/p/chromium/issues/detail?id=1098275

Setting the component in order to involve the development team.

Component: Untriaged → DOM: Events
Product: Firefox → Core

How is the defined in the spec?

Considering the behavior is consistent with other browsers, we shouldn't rush to do this, no matter what the spec definition is.

Severity: -- → S3
Flags: needinfo?(echen)
Priority: -- → P3

Dispatching click event isn't the default action of a mousedown event, nor mouseup event. And spec doesn't define that we should suppress click event if preventDefault() is called in mousedown/mouseup event handler. This is a legacy behavior, all browser behave the same, change this would cause massive compatibility problems.

Severity: S3 → S4
Flags: needinfo?(echen)
Priority: P3 → P5

That's a shame, but understandable.

So I guess we as web page developers will have to continue adding handlers just to do preventDefault() on click? Or is there something else that is recommended to state that we want to handle the mouse events fully ourselves?

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: