Last Comment Bug 556493 - No click fired when mousedown on the text of an element and mouseup on empty area
: No click fired when mousedown on the text of an element and mouseup on empty ...
Product: Core
Classification: Components
Component: DOM: Events (show other bugs)
: unspecified
: x86 Mac OS X
: -- normal (vote)
: ---
Assigned To: Olli Pettay [:smaug]
: Andrew Overholt [:overholt]
Depends on: 1312867
  Show dependency treegraph
Reported: 2010-04-01 04:54 PDT by Janne Aukia
Modified: 2016-10-25 20:03 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Example of the problem (546 bytes, text/html)
2010-04-01 04:55 PDT, Janne Aukia
no flags Details
patch (892 bytes, patch)
2010-06-04 12:31 PDT, Olli Pettay [:smaug]
no flags Details | Diff | Splinter Review
with tests (3.67 KB, patch)
2010-06-04 14:17 PDT, Olli Pettay [:smaug]
jst: review+
Details | Diff | Splinter Review

Description Janne Aukia 2010-04-01 04:54:17 PDT
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; fi-fi) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; fi; rv: Gecko/20100316 Firefox/3.6.2

A div with text, when you mouse down on the text and mouse up outside the text, no click event is fired, even though the event targets are the same for mousedown and mouseup.

The same surprising behaviour happens in Safari as well.

Reproducible: Always
Comment 1 Janne Aukia 2010-04-01 04:55:09 PDT
Created attachment 436452 [details]
Example of the problem
Comment 2 Janne Aukia 2010-04-01 04:59:06 PDT
This would seem to be related to: . The difference is that no visible parent-child-relationship is needed, but the problem occurs with a div with text content as well.
Comment 3 Olli Pettay [:smaug] 2010-04-01 05:37:51 PDT
This is possibly the behavior we need to keep for backward compatibility.
I'll bring this up on WebApps WG / DOM 3 Events.
Comment 4 Olli Pettay [:smaug] 2010-04-01 05:39:02 PDT
And the behavior doesn't seem too surprising.
When text is clicked, user clicks actually a text node, and then releasing
happens on the div element.
Comment 5 Janne Aukia 2010-04-01 05:47:37 PDT
Thanks for the response!

In practice, this problem shows up with, for example, links that have been styled like buttons by adding padding and background to them. When the user mousedowns on the link text but mouseups in the padded area, the event does not fire. For the user, the button feels like randomly working and not working, since even a small movement of the mouse while clicking the link might prevent the click event.

Work around is to track the mousedown and up elements with javascript, but it is quite difficult. Or to just respond to mouseup event, with the risk of user accidentally mouseupping over a wrong button.
Comment 6 Olli Pettay [:smaug] 2010-04-07 11:21:39 PDT
Ok, per current DOM 3 Events draft the click event should be fired.
I'll change this and hopefully the change doesn't cause too many regressions.
Comment 7 Janne Aukia 2010-04-13 23:31:47 PDT
Comment 8 Olli Pettay [:smaug] 2010-06-04 12:31:53 PDT
Created attachment 449318 [details] [diff] [review]

I pushed the patch to tryserver.
If everything looks good there, I'll write the tests and ask reviews.
Comment 9 Olli Pettay [:smaug] 2010-06-04 14:17:49 PDT
Created attachment 449341 [details] [diff] [review]
with tests

This may break something on the web, so would be great to get this in
reasonable soon.
Comment 10 Olli Pettay [:smaug] 2010-06-15 05:37:32 PDT
Oops, I need to remember to land this.
Will do later today.
Comment 11 :Ehsan Akhgari 2010-11-20 13:14:35 PST
This was landed in:

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