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

TestUtils.Simulate.mouseDown() doesn't trigger focus event #2336

Closed
ikokostya opened this issue Oct 13, 2014 · 3 comments
Closed

TestUtils.Simulate.mouseDown() doesn't trigger focus event #2336

ikokostya opened this issue Oct 13, 2014 · 3 comments

Comments

@ikokostya
Copy link

This code

/** @jsx React.DOM */

var Button = React.createClass({
  render: function() {
    return (
      <button
        onMouseDown={this.handleMouseDown}
        onFocus={this.handleFocus}
      >Test</button>
    );
  },

  handleMouseDown: function() {
    console.log('handle mouse down');
  },

  handleFocus: function() {
    console.log('handle focus');
  }
});

var button = React.renderComponent(
  <Button />,
  document.getElementById('content')
);

React.addons.TestUtils.Simulate.mouseDown(button.getDOMNode());

outputs

handle mouse down

Expected output (like in real browser):

handle mouse down
handle focus

Demo http://jsbin.com/pasovu/4

@ikokostya
Copy link
Author

It's correct behavior. Sorry for this issue.

@przeor
Copy link

przeor commented Jul 1, 2015

Isn't:

React.addons.TestUtils.Simulate.mouseDown(button.getDOMNode());
React.addons.TestUtils.Simulate.focus(button.getDOMNode());

the answer that may help you?

Output:

handle mouse down
handle focus

@ivandiazwm
Copy link

But if I do preventDefault on the event generated by Simulate, it won't prevent focus.

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

3 participants