mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: call onSelect plugin callbacks for noop rows (#6682)
This commit is contained in:
parent
6b433b66f5
commit
8da8f5d0f7
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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:
|
||||
'<span class="on-select-test"></span>{{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();
|
||||
}
|
||||
});
|
||||
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user