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

Firefox mouseleave@document action does not work #699

Open
papppeter opened this issue Jul 4, 2023 · 2 comments
Open

Firefox mouseleave@document action does not work #699

papppeter opened this issue Jul 4, 2023 · 2 comments

Comments

@papppeter
Copy link

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.

@papppeter papppeter changed the title Firefox mouseleave@document does not work Firefox mouseleave@document action does not work Jul 4, 2023
@papppeter
Copy link
Author

Firefox version is: 113.0.2

@lb-
Copy link
Contributor

lb- commented Jul 4, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants