mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: call onSelect plugin callbacks for noop rows (#6682)
This commit is contained in:
@ -265,6 +265,12 @@ export default SelectKitComponent.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (computedContentItem.__sk_row_type === "noopRow") {
|
if (computedContentItem.__sk_row_type === "noopRow") {
|
||||||
|
applyOnSelectPluginApiCallbacks(
|
||||||
|
this.get("pluginApiIdentifiers"),
|
||||||
|
computedContentItem.value,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
this._boundaryActionHandler("onSelect", computedContentItem.value);
|
this._boundaryActionHandler("onSelect", computedContentItem.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -211,6 +211,12 @@ export default SelectKitComponent.extend({
|
|||||||
|
|
||||||
select(computedContentItem) {
|
select(computedContentItem) {
|
||||||
if (computedContentItem.__sk_row_type === "noopRow") {
|
if (computedContentItem.__sk_row_type === "noopRow") {
|
||||||
|
applyOnSelectPluginApiCallbacks(
|
||||||
|
this.get("pluginApiIdentifiers"),
|
||||||
|
computedContentItem.value,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
this._boundaryActionHandler("onSelect", computedContentItem.value);
|
this._boundaryActionHandler("onSelect", computedContentItem.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import componentTest from "helpers/component-test";
|
import componentTest from "helpers/component-test";
|
||||||
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
|
import { clearCallbacks } from "select-kit/mixins/plugin-api";
|
||||||
|
|
||||||
moduleForComponent("multi-select", {
|
moduleForComponent("multi-select", {
|
||||||
integration: true,
|
integration: true,
|
||||||
beforeEach: function() {
|
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) {
|
async test(assert) {
|
||||||
@ -497,6 +500,15 @@ componentTest("support modifying on select behavior through plugin api", {
|
|||||||
|
|
||||||
assert.equal(find(".on-select-test").html(), "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();
|
clearCallbacks();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user