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

jQuery erroneously calls pointerleave handlers when entering a descendent input textbox in Chrome #3490

Closed
lpd-au opened this issue Jan 10, 2017 · 4 comments
Labels

Comments

@lpd-au
Copy link

lpd-au commented Jan 10, 2017

Description

  1. Attach a pointerleave handler to an element with an input descendant textbox using jQuery.
  2. Attach a pointerleave handler to the same element using native javascript.
  3. Starting outside the container element, move your mouse into it and over the textbox.

Expected behaviour: no events will fire.
Actual behaviour: in Chrome, the jQuery event handler is called but not the native event handler. Expected behaviour occurs in Firefox (with feature flag) and Edge.

Just to emphasize, using otherwise identical test code, I can only reproduce this in one browser when the event handlers are added using .on and not .addEventListener. Substituting those two functions was the fix for my web app.

Tested on a 1.25x scaled, touchscreen Windows 10 laptop in Chrome 56 (beta), Firefox 52 (dev edn), Edge 14.

Link to test case

jQuery 1.12.4: https://jsfiddle.net/od2f7wnm/ (fail)
jQuery 1.x tip: https://jsfiddle.net/od2f7wnm/1/ (fail)
jQuery 3.1.1: https://jsfiddle.net/od2f7wnm/2/ (fail)
jQuery 3.x tip: https://jsfiddle.net/od2f7wnm/3/ (fail)
Native JS: https://jsfiddle.net/3ugj8nor/ (pass)

@dmethvin
Copy link
Member

Whoa, nice one!

In order to support delegated events on mouse or pointer enter/leave, jQuery uses the corresponding over/out event and then looks at the event.relatedTarget to determine whether the pointer is actually entering or leaving the parent element. There seems to be a bug in Chrome's pointerout event where event.relatedTarget is reporting a shadow DOM element inside the input's shadow DOM called #inner-editor where it should be reporting the input. When jQuery can't find that element in the current document it thinks the pointer must have left the building and fires the pointerleave event.

You can see the problem in action if you turn on Settings, "Show user agent shadow DOM" and inspect the input. Screen shot attached.

capture

@dmethvin
Copy link
Member

@RByers does that look like a bug to you?

@RByers
Copy link

RByers commented Jan 12, 2017

Whoa yes - that's a Chrome bug. Thanks and sorry for the trouble! We'll get it fixed ASAP (likely Chrome 57) - I'm guessing it won't be too hard.

@markelog
Copy link
Member

Chrome patch is in, sounds like we good here

@markelog markelog added the Event label Jan 29, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

4 participants