diff --git a/src/collections/Form/Form.js b/src/collections/Form/Form.js index 7739df0bc1..03ab8055d1 100644 --- a/src/collections/Form/Form.js +++ b/src/collections/Form/Form.js @@ -102,7 +102,7 @@ class Form extends Component { // Heads up! Third party libs can pass own data as first argument, we need to check that it has preventDefault() // method. - if (!action) _.invoke(e, 'preventDefault') + if (typeof action !== 'string') _.invoke(e, 'preventDefault') _.invoke(this.props, 'onSubmit', e, this.props, ...args) } diff --git a/test/specs/collections/Form/Form-test.js b/test/specs/collections/Form/Form-test.js index 66efebbe54..b82099f135 100644 --- a/test/specs/collections/Form/Form-test.js +++ b/test/specs/collections/Form/Form-test.js @@ -67,7 +67,13 @@ describe('Form', () => { shallow(
) .simulate('submit', event) - event.preventDefault.should.have.been.calledOnce() + shallow() + .simulate('submit', event) + + shallow() + .simulate('submit', event) + + event.preventDefault.should.have.been.calledThrice() }) it('does not prevent default on the event when there is an action', () => { @@ -76,6 +82,9 @@ describe('Form', () => { shallow() .simulate('submit', event) + shallow() + .simulate('submit', event) + event.preventDefault.should.not.have.been.called() })