Closed
Bug 1446832
Opened 8 years ago
Closed 8 years ago
Hover state still set on element during mouseleave event.
Categories
(Core :: DOM: Events, defect)
Tracking
()
RESOLVED
FIXED
mozilla61
| Tracking | Status | |
|---|---|---|
| firefox61 | --- | fixed |
People
(Reporter: gfiore, Assigned: emilio)
References
Details
Attachments
(3 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
Steps to reproduce:
I can reproduce the error consistently by following these steps:
1) Create an HTML element and give it an id (let's say it's id is 'elem1').
2) Create a Javascript "mouseleave" event listener on that HTML element and corresponding function to be executed. In that function check which element(s) in the DOM has the :hover property (using any of the many ways to select elements with :hover). Also check which element(s) the cursor is currently over using document.elementFromPoint(event.clientX, event.clientY).
Actual results:
When the event is triggered and the above corresponding function is executed, the :hover selector returns that 'elem1' (and only 'elem1') is currently the element hovered over. However, document.elementFromPoint() returns that the element currently under the cursor is NOT 'elem1' - it is whatever element is next to (or behind) 'elem1'.
Expected results:
When a 'mouseleave' event is triggered for an element (in this case 'elem1') the cursor is no longer over that element and thus the element should no longer be selectable with :hover. Instead, the element that the cursor is currently over should be selectable with :hover. This is the behavior demonstrated by Chrome, Safari, Opera, etc.
| Assignee | ||
Comment 1•8 years ago
|
||
Could you attach a test-case, using the "Attach file" link in bugzilla? It'd be much easier to see and debug.
Thanks!
Flags: needinfo?(gfiore)
| Assignee | ||
Comment 2•8 years ago
|
||
(I suspect we're just updating the hover state after dispatching the element or something like that...)
| Assignee | ||
Comment 3•8 years ago
|
||
Well, I just got curious myself, though it's late in Europe... :P
Should never print "element", but it does.
Flags: needinfo?(gfiore)
| Assignee | ||
Updated•8 years ago
|
Summary: Hover property still set on element after cursor has already left. → Hover state still set on element during mouseleave event.
| Assignee | ||
Updated•8 years ago
|
Status: UNCONFIRMED → NEW
Component: DOM: CSS Object Model → DOM: Events
Ever confirmed: true
| Reporter | ||
Comment 4•8 years ago
|
||
This is the simple test case I used.
| Reporter | ||
Comment 5•8 years ago
|
||
The test case I used shows effectively the same behavior as yours it looks like. Thanks for recategorizing - wasn't sure if this should land in CSS Object or Events.
| Assignee | ||
Comment 6•8 years ago
|
||
So, the relevant code is here:
https://searchfox.org/mozilla-central/rev/3abf6fa7e2a6d9a7bfb88796141b0f012e68c2db/dom/events/EventStateManager.cpp#4351
Note how we NotifyMouseOut (which triggers the mouseleave event), _then_ set the hover state on the new node (unsetting it later), _then_ dispatch mouseenter on the new one.
It may just be a matter of reordering those...
| Assignee | ||
Comment 7•8 years ago
|
||
Are you interested in fixing this by any chance?
Happy to mentor if so, though probably someone more familiar with the events code may be a more suitable reviewer :).
It may be a matter of writing that patch as suggested in comment 6 and write an automated test (which can be a bit harder, you need to synthesize events). You could probably use:
https://searchfox.org/mozilla-central/rev/3abf6fa7e2a6d9a7bfb88796141b0f012e68c2db/layout/style/test/test_hover_quirk.html#71
as a guide.
Otherwise I can try to fix it myself I guess :)
Flags: needinfo?(gfiore)
| Assignee | ||
Comment 8•8 years ago
|
||
| Reporter | ||
Comment 9•8 years ago
|
||
I would be interested in fixing it, but I'm extremely busy right now and won't be able to look at it for another few days. If you (or anyone else) want to fix it in the meantime please feel free to.
Flags: needinfo?(gfiore)
| Assignee | ||
Comment 10•8 years ago
|
||
(In reply to Gawan Fiore from comment #9)
> I would be interested in fixing it, but I'm extremely busy right now and
> won't be able to look at it for another few days. If you (or anyone else)
> want to fix it in the meantime please feel free to.
Ok, will do, thanks!
If you want any other bug to fix or something once you have more time feel free to reach out to me either over email or IRC :)
Assignee: nobody → emilio
Comment 11•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
Attachment #8960163 -
Flags: review?(bugs)
Comment 12•8 years ago
|
||
Comment on attachment 8960163 [details]
Bug 1446832: Update hover state before firing mouseleave, to match other browsers. r=smaug
Olli Pettay [:smaug] has approved the revision.
https://phabricator.services.mozilla.com/D772
Attachment #8960163 -
Flags: review+
Updated•8 years ago
|
Attachment #8960163 -
Flags: review?(bugs)
Comment 13•8 years ago
|
||
Pushed by ecoal95@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/62fbfdc5ac11
Update hover state before firing mouseleave, to match other browsers. r=smaug
Comment 14•8 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox61:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in
before you can comment on or make changes to this bug.
Description
•