Skip to content

A platform for community discussion. Free, open, simple.

FIX: prevents click on sk header to bubble (#9084)

Joffrey JAFFEUXed85cfe1419f
diff --git a/app/assets/javascripts/select-kit/components/select-kit/select-kit-header.js.es6 b/app/assets/javascripts/select-kit/components/select-kit/select-kit-header.js.es6
index faf8f27b7ec..6ec3984a98e 100644
--- a/app/assets/javascripts/select-kit/components/select-kit/select-kit-header.js.es6
+++ b/app/assets/javascripts/select-kit/components/select-kit/select-kit-header.js.es6
@@ -13,6 +13,7 @@ export default Component.extend(UtilsMixin, {
return;
if (this.eventType !== "click" || event.button !== 0) return;
this.selectKit.toggle(event);
+ return false;
},
classNames: ["select-kit-header"],
diff --git a/test/javascripts/components/select-kit/single-select-test.js.es6 b/test/javascripts/components/select-kit/single-select-test.js.es6
index 42f058a5862..88dbbacf9ee 100644
--- a/test/javascripts/components/select-kit/single-select-test.js.es6
+++ b/test/javascripts/components/select-kit/single-select-test.js.es6
@@ -238,3 +238,22 @@ componentTest("selected value can be 0", {
assert.equal(this.subject.header().value(), 0);
}
});
+
+componentTest("prevents propagating click event on header", {
+ template:
+ "{{#d-button icon='times' action=onClick}}{{single-select value=value content=content}}{{/d-button}}",
+
+ beforeEach() {
+ this.setProperties({
+ onClick: () => this.set("value", "foo"),
+ content: DEFAULT_CONTENT,
+ value: DEFAULT_VALUE
+ });
+ },
+
+ async test(assert) {
+ assert.equal(this.value, DEFAULT_VALUE);
+ await this.subject.expand();
+ assert.equal(this.value, DEFAULT_VALUE);
+ }
+});