diff --git a/app/assets/javascripts/select-kit/components/multi-select.js.es6 b/app/assets/javascripts/select-kit/components/multi-select.js.es6 index 2dc640824ac..ed64094062a 100644 --- a/app/assets/javascripts/select-kit/components/multi-select.js.es6 +++ b/app/assets/javascripts/select-kit/components/multi-select.js.es6 @@ -265,6 +265,12 @@ export default SelectKitComponent.extend({ } if (computedContentItem.__sk_row_type === "noopRow") { + applyOnSelectPluginApiCallbacks( + this.get("pluginApiIdentifiers"), + computedContentItem.value, + this + ); + this._boundaryActionHandler("onSelect", computedContentItem.value); return; } diff --git a/app/assets/javascripts/select-kit/components/single-select.js.es6 b/app/assets/javascripts/select-kit/components/single-select.js.es6 index 4e18f7382b7..66e13bff38b 100644 --- a/app/assets/javascripts/select-kit/components/single-select.js.es6 +++ b/app/assets/javascripts/select-kit/components/single-select.js.es6 @@ -211,6 +211,12 @@ export default SelectKitComponent.extend({ select(computedContentItem) { if (computedContentItem.__sk_row_type === "noopRow") { + applyOnSelectPluginApiCallbacks( + this.get("pluginApiIdentifiers"), + computedContentItem.value, + this + ); + this._boundaryActionHandler("onSelect", computedContentItem.value); return; } diff --git a/test/javascripts/components/multi-select-test.js.es6 b/test/javascripts/components/multi-select-test.js.es6 index ea13a619082..81c07bd5cae 100644 --- a/test/javascripts/components/multi-select-test.js.es6 +++ b/test/javascripts/components/multi-select-test.js.es6 @@ -1,4 +1,7 @@ import componentTest from "helpers/component-test"; +import { withPluginApi } from "discourse/lib/plugin-api"; +import { clearCallbacks } from "select-kit/mixins/plugin-api"; + moduleForComponent("multi-select", { integration: true, beforeEach: function() { @@ -317,3 +320,39 @@ componentTest("with forceEscape", { ); } }); + +componentTest("support modifying on select behavior through plugin api", { + template: + '{{multi-select content=content}}', + + beforeEach() { + withPluginApi("0.8.13", api => { + api.modifySelectKit("select-kit").onSelect((context, value) => { + find(".on-select-test").html(value); + }); + }); + + this.set("content", [ + { id: "1", name: "robin" }, + { id: "2", name: "arpit", __sk_row_type: "noopRow" } + ]); + }, + + async test(assert) { + await this.get("subject").expand(); + await this.get("subject").selectRowByValue(1); + + assert.equal(find(".on-select-test").html(), "1"); + + await this.get("subject").expand(); + await this.get("subject").selectRowByValue(2); + + assert.equal( + find(".on-select-test").html(), + "2", + "it calls onSelect for noopRows" + ); + + clearCallbacks(); + } +}); diff --git a/test/javascripts/components/single-select-test.js.es6 b/test/javascripts/components/single-select-test.js.es6 index a56157b5804..2b65db868cd 100644 --- a/test/javascripts/components/single-select-test.js.es6 +++ b/test/javascripts/components/single-select-test.js.es6 @@ -488,7 +488,10 @@ componentTest("support modifying on select behavior through plugin api", { }); }); - this.set("content", [{ id: "1", name: "robin" }]); + this.set("content", [ + { id: "1", name: "robin" }, + { id: "2", name: "arpit", __sk_row_type: "noopRow" } + ]); }, async test(assert) { @@ -497,6 +500,15 @@ componentTest("support modifying on select behavior through plugin api", { assert.equal(find(".on-select-test").html(), "1"); + await this.get("subject").expand(); + await this.get("subject").selectRowByValue(2); + + assert.equal( + find(".on-select-test").html(), + "2", + "it calls onSelect for noopRows" + ); + clearCallbacks(); } });