Skip to content

Button’s eat all mouse events. #1973

@iamdustan

Description

@iamdustan

I’m unsure if this is react specific or just how browsers do things, but there is some difference in cross-browser behavior. I tested this with both React 0.10 and 0.11.

The following pattern fires all event handlers in Chrome and Safari, and only the button onClick handler in Firefox.

http://jsbin.com/saxotoqi/1/edit

var Button = React.createClass({
  onClick: function(e) {
    console.log('onClick');
  },
  handleDown: function(e) {
    console.log('handleDown');
  },
  handleUp: function(e) {
    console.log('handleUp');
  },
  render: function() {
    return (
      React.DOM.button({onClick: this.onClick}, 
        'Hello',
        React.DOM.canvas({onMouseDown: this.handleDown, onMouseUp: this.handleUp})
      )
    );
  }
});

React.renderComponent(Button(), document.body);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions