diff --git a/src/wrappers/wrapper.js b/src/wrappers/wrapper.js index efc9fc730..3851a50fc 100644 --- a/src/wrappers/wrapper.js +++ b/src/wrappers/wrapper.js @@ -522,6 +522,11 @@ export default class Wrapper implements BaseWrapper { throwError('you cannot set the target value of an event. See the notes section of the docs for more details—https://vue-test-utils.vuejs.org/en/api/wrapper/trigger.html') } + // Don't fire event on a disabled element + if (this.attributes().disabled) { + return + } + const modifiers = { enter: 13, tab: 9, diff --git a/test/specs/wrapper/trigger.spec.js b/test/specs/wrapper/trigger.spec.js index c2c42c634..90e516fe4 100644 --- a/test/specs/wrapper/trigger.spec.js +++ b/test/specs/wrapper/trigger.spec.js @@ -93,6 +93,21 @@ describeWithShallowAndMount('trigger', (mountingMethod) => { expect(clickHandler.calledOnce).to.equal(true) }) + it('does not fire on disabled elements', () => { + const clickHandler = sinon.stub() + const TestComponent = { + template: '