Skip to content

onMouseOver is not triggered for a component rendered under the mouse until the mouse moves. #2621

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

Closed
z5h opened this issue Nov 28, 2014 · 4 comments

Comments

@z5h
Copy link

z5h commented Nov 28, 2014

If a component is rendered that registers for onMouseOver events, and it is rendered under the mouse, it should have it's onMouseOver callback invoked.

@z5h
Copy link
Author

z5h commented Nov 28, 2014

A temporary fix is something like this:

  componentDidMount : function(){
    //Check if we were rendered under the mouse, and if so,
    //trigger an onMouseEnter event.
    //This needs to be called from a setTimeout otherwise the browser won't have
    //a chance to set :hover state.
    var myNode = this.getDOMNode();
    setTimeout(function(){
      if (myNode.parentElement.querySelector(':hover') === myNode){
        this. onMouseOver();
      }
    }.bind(this), 0);
  }

@santiagopuentep
Copy link

Also, mouseEnter event never triggers.

@bvaughn
Copy link
Contributor

bvaughn commented Jun 9, 2017

I don't think React should implement the behavior described in this issue. It's not React-specific. Certain browsers (eg Chrome, Safari) don't dispatch a mouseover or mouseenter event in the case you've described (even using vanilla JS) until the mouse moves again. I don't think React should try to iron over this behavior.

I'm going to close this issue for now. We can always reopen it if other's feel strongly. 😄

@getusha
Copy link

getusha commented Dec 18, 2022

Experiencing the same issue.
it works on chrome, firefox
on safari onMouseOver callback is not invoked until the mouse moves.

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

No branches or pull requests

4 participants