Skip to content

Commit

Permalink
fix(Button): Stop event bubbling when clicked
Browse files Browse the repository at this point in the history
Fixes #347
  • Loading branch information
simonihmig committed Jun 9, 2017
1 parent f487ecd commit a2d123b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addon/components/base/bs-button.js
Expand Up @@ -270,6 +270,8 @@ export default Ember.Component.extend(TypeClass, SizeClass, {
}
);
}

return false;
},

init() {
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/components/bs-button-test.js
Expand Up @@ -143,3 +143,16 @@ test('clicking a button sends onclick action, if promise is returned from closur
assert.equal(find('button').textContent, 'resolved');

});

test('clicking a button will prevent event to bubble up', async function(assert) {
let buttonClick = this.spy();
this.on('buttonClick', buttonClick);
let parentClick = this.spy();
this.on('parentClick', parentClick);

this.render(hbs`<div {{action "parentClick"}}>{{#bs-button onClick=(action "buttonClick")}}Button{{/bs-button}}</div>`);

await click('button');
assert.ok(buttonClick.called);
assert.notOk(parentClick.called);
});

0 comments on commit a2d123b

Please sign in to comment.