Skip to content

Commit

Permalink
Fix double-firing submit events (#12877)
Browse files Browse the repository at this point in the history
We were adding a listener at the root when we weren't meant to. Blames to e96dc14.

This now alerts once (at FORM) instead of twice (at FORM, #document):

```
var Hello = class extends React.Component {
  render() {
    return (
      <form onSubmit={(e) => {e.preventDefault(); alert('hi ' + e.nativeEvent.currentTarget.nodeName);}}>
        <button>hi</button>
      </form>
    );
  }
};
```
  • Loading branch information
sophiebits authored May 22, 2018
1 parent 60853f0 commit ad27845
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react-dom/src/events/ReactBrowserEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
TOP_CANCEL,
TOP_CLOSE,
TOP_FOCUS,
TOP_RESET,
TOP_SCROLL,
TOP_SUBMIT,
} from './DOMTopLevelEventTypes';
import {
setEnabled,
Expand Down Expand Up @@ -147,7 +149,7 @@ export function listenTo(
trapCapturedEvent(TOP_CLOSE, mountAt);
}
isListening[TOP_CLOSE] = true;
} else {
} else if (dependency !== TOP_SUBMIT && dependency !== TOP_RESET) {
trapBubbledEvent(dependency, mountAt);
}

Expand Down

0 comments on commit ad27845

Please sign in to comment.