Firefox mouseleave@document action does not work
papppeter opened this issue · comments
My problem is that mouseleave@document at firefox does not work, there are some workaround which could make it work, but i cannot implement it inside stimulus.
This shows clearly the issue
https://stackoverflow.com/questions/66245558/mouseenter-and-mouseleave-event-listeners-on-document-not-working-in-firefox
document.addEventListener("mouseenter", () => {
console.log("mouseenter");
});
does not work on firefox
document.querySelector("body").addEventListener("mouseenter", () => {
console.log("mouseenter");
});
or
document.documentElement.addEventListener('mouseleave', () => {})
does work.
any hint how i could make it work?
thanks for suggestions
my action data looks like following:
data-action="mouseleave@document->newsletter-popup#show"
which works perfeclty under chrome.
Firefox version is: 113.0.2
Have you tried mouseout
, as mouseleave
does not bubble.
Hence Firefox may be more correct here, as your cursor is unlikely to leave the body or document element.
But mouseout will trigger when any descendant elements have a mouse move out of them.
https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseleave_event
Also, this is not really a Stimulus problem as Stimulus actions are just a shortcut to attaching event listeners.