diff --git a/packages/@ember/-internals/glimmer/tests/integration/helpers/element-action-test.js b/packages/@ember/-internals/glimmer/tests/integration/helpers/element-action-test.js index 6de7ff99412..f3f8d4c5a6a 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/helpers/element-action-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/helpers/element-action-test.js @@ -1359,6 +1359,40 @@ moduleFor( this.assert.ok(doubleClickActionWasCalled, 'the doubleClicked action was called'); } + ['@test allows multiple actions for same event on a single element']() { + let clickAction1WasCalled = false; + let clickAction2WasCalled = false; + + let ExampleComponent = Component.extend({ + actions: { + clicked1() { + clickAction1WasCalled = true; + }, + clicked2() { + clickAction2WasCalled = true; + }, + }, + }); + + this.registerComponent('example-component', { + ComponentClass: ExampleComponent, + template: strip` + click me`, + }); + + this.render('{{example-component}}'); + + runTask(() => { + this.$('a').trigger('click'); + }); + + this.assert.ok(clickAction1WasCalled, 'the first clicked action was called'); + this.assert.ok(clickAction2WasCalled, 'the second clicked action was called'); + } + ['@test it should respect preventDefault option if provided']() { let ExampleComponent = Component.extend({ actions: { diff --git a/packages/@ember/-internals/views/lib/system/event_dispatcher.js b/packages/@ember/-internals/views/lib/system/event_dispatcher.js index 3af4a24536b..1c139bdbac5 100644 --- a/packages/@ember/-internals/views/lib/system/event_dispatcher.js +++ b/packages/@ember/-internals/views/lib/system/event_dispatcher.js @@ -285,13 +285,16 @@ export default EmberObject.extend({ return; } + let result = true; for (let index = 0; index < actions.length; index++) { let action = actions[index]; if (action && action.eventName === eventName) { - return action.handler(event); + // return false if any of the action handlers returns false + result = result && action.handler(event); } } + return result; }; // Special handling of events that don't bubble (event delegation does not work).