No click fired when mousedown in child element and mouseup in parent element

RESOLVED INVALID

Status

()

Core
DOM: Events
RESOLVED INVALID
12 years ago
2 years ago

People

(Reporter: Martijn Wargers (dead), Unassigned)

Tracking

({testcase})

Trunk
x86
Windows XP
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments, 2 obsolete attachments)

(Reporter)

Description

12 years ago
See upcoming testcase.

To reproduce:
- Mousedown on the yellow block, hold down your mouse button
- Move the mouse into the green block
- Release mouse button

I get no 'click' alert in Mozilla.
Should I get a 'click' alert or not? (IE6 generates a 'click' alert)
(Reporter)

Comment 1

12 years ago
Created attachment 211541 [details]
testcase
Opera9tp2 shows no click too. (Same as firefox)
(Reporter)

Comment 3

12 years ago
This is what dom level 2 has to say:
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-mouseevents-h3
"
click
    The click event occurs when the pointing device button is clicked over an element. A click is defined as a mousedown and mouseup over the same screen location. The sequence of these events is:
"
Not very clear to me what that means in this situation.

Imho, IE6 seems to make more sense to me.
Blocks: 324396
Note that this might be more of an "event handling" issue (as in, the fix will be in the ESM, not in DOM event code).

Comment 5

11 years ago
This is not a bug.

According to SVG specifications you should never get a Click event if you have moved the mouse between mousedown and mouseup.
That on the other hand is a bug. (Mozilla does sometimes generate clicks when the mouse has moved between mousedown and mouseup) See: https://bugzilla.mozilla.org/show_bug.cgi?id=319347

I don't know why you are getting click events in IE6 using your testcase. If you try the testcase in bug# 319347 you will see that IE6 does not generate click events if the mouse has moved between mousedown and mouseup. That is the correct behaviour.

If you want an event when the mouse button is released in your testcase, you should use the "mouseup" event, not the click event.
(In reply to comment #5)
> According to SVG specifications you should never get a Click event if you have
> moved the mouse between mousedown and mouseup.

Er, what has SVG do with this ?

Comment 7

11 years ago
> click
>     The click event occurs when the pointing device button is clicked over an
> element. A click is defined as a mousedown and mouseup over the same screen
> location. The sequence of these events is:
> "

I believe the mousedown and the mouseup event should fire over the *same* element in order to be considered a click event. Otherwise, it's not a true click on a single element but rather mouse-dragging or text selection or selection (highlighting). My 2 cents.
(Reporter)

Comment 8

11 years ago
Created attachment 254414 [details]
testcase2

Here the yellow block disappears on mousedown.
Opera9 and IE7 generate a click event in this case,
but in Opera9, if you move the mouse after mousedown and before you mouseup, the click alert isn't fired.
Assignee: events → nobody
QA Contact: ian → events

Comment 9

7 years ago
Created attachment 540854 [details]
element with :active style moves so click is lost near the edge

click event is attached to the outer div, the inner div has an active style that repositions it slightly. Clicking near the border of the inner div will be lost because the mousedown div is different than the mouseup div.

Comment 10

7 years ago
Created attachment 540856 [details]
element with :active style moves so click is lost near the edge v2

click event is attached to the outer div, the inner div has an active style that repositions it slightly. Clicking near the border of the inner div will be lost because the mousedown div is different than the mouseup div.
Attachment #540854 - Attachment is obsolete: true

Comment 11

7 years ago
Created attachment 540858 [details]
element with :active style moves so click is lost near the edge v3

click event is attached to the outer div, the inner div has an active style that repositions it slightly. Clicking near the border of the inner div will be lost because the mousedown div is different than the mouseup div.
Attachment #540856 - Attachment is obsolete: true
Based on DOM 3 Events this is invalid.
mousedown and mouseup must happen on the same element.
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → INVALID

Comment 13

2 years ago
This was asked on http://stackoverflow.com/q/34029785/1026, so I researched it a bit.

The current location of the spec seems to be: https://w3c.github.io/uievents/#event-type-click
from my reading of it, it implies that our current behaviour is the expected one, but I can't see where in the normative text it says that.

IE and Chrome currently fire a 'click' (on the common ancestor?), but both have bugs filed about this:

Chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=484655
IE bug: https://connect.microsoft.com/IE/feedback/details/809003/unexpected-click-event-triggered-when-the-elements-below-cursor-at-mousedown-and-mouseup-events-are-different
You need to log in before you can comment on or make changes to this bug.