mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: ensures onSelect/onDeselect are called
This commit also add a FIX and a test for toolbar-popup-menu-options which had a behavior slightly specific.
This commit is contained in:
parent
fadcd36f92
commit
a713c0d366
@ -15,7 +15,7 @@
|
|||||||
{{#each group.buttons as |b|}}
|
{{#each group.buttons as |b|}}
|
||||||
{{#if b.popupMenu}}
|
{{#if b.popupMenu}}
|
||||||
{{toolbar-popup-menu-options
|
{{toolbar-popup-menu-options
|
||||||
onPopupMenuAction=onPopupMenuAction
|
onSelect=onPopupMenuAction
|
||||||
onExpand=(action b.action b)
|
onExpand=(action b.action b)
|
||||||
title=b.title
|
title=b.title
|
||||||
headerIcon=b.icon
|
headerIcon=b.icon
|
||||||
|
@ -210,6 +210,10 @@ export default SelectKitComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
select(computedContentItem) {
|
select(computedContentItem) {
|
||||||
|
if (this.get("hasSelection")) {
|
||||||
|
this.deselect(this.get("selection.value"));
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!computedContentItem ||
|
!computedContentItem ||
|
||||||
computedContentItem.__sk_row_type === "noneRow"
|
computedContentItem.__sk_row_type === "noneRow"
|
||||||
|
@ -12,10 +12,7 @@ export default DropdownSelectBoxComponent.extend({
|
|||||||
return `<h3>${title}</h3>`;
|
return `<h3>${title}</h3>`;
|
||||||
},
|
},
|
||||||
|
|
||||||
mutateValue(value) {
|
autoHighlight() {},
|
||||||
this.sendAction("onPopupMenuAction", value);
|
|
||||||
this.setProperties({ value: null, highlighted: null });
|
|
||||||
},
|
|
||||||
|
|
||||||
computeContent(content) {
|
computeContent(content) {
|
||||||
return content
|
return content
|
||||||
|
@ -289,6 +289,35 @@ QUnit.test("Composer can toggle between edit and reply", async assert => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test("Composer can toggle whispers", async assert => {
|
||||||
|
await visit("/t/this-is-a-test-topic/9");
|
||||||
|
await click(".topic-post:eq(0) button.reply");
|
||||||
|
|
||||||
|
await selectKit(".toolbar-popup-menu-options").expand();
|
||||||
|
await selectKit(".toolbar-popup-menu-options").selectRowByValue(
|
||||||
|
"toggleWhisper"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
find(".composer-fields .whisper")
|
||||||
|
.text()
|
||||||
|
.indexOf(I18n.t("composer.whisper")) > 0,
|
||||||
|
"it sets the post type to whisper"
|
||||||
|
);
|
||||||
|
|
||||||
|
await selectKit(".toolbar-popup-menu-options").expand();
|
||||||
|
await selectKit(".toolbar-popup-menu-options").selectRowByValue(
|
||||||
|
"toggleWhisper"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
find(".composer-fields .whisper")
|
||||||
|
.text()
|
||||||
|
.indexOf(I18n.t("composer.whisper")) <= 0,
|
||||||
|
"it removes the whisper mode"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test(
|
QUnit.test(
|
||||||
"Composer can toggle between reply and createTopic",
|
"Composer can toggle between reply and createTopic",
|
||||||
async assert => {
|
async assert => {
|
||||||
|
@ -835,3 +835,55 @@ componentTest("without forceEscape", {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
componentTest("onSelect", {
|
||||||
|
template:
|
||||||
|
"<div class='test-external-action'></div>{{single-select content=content onSelect=(action externalAction)}}",
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
this.set("externalAction", actual => {
|
||||||
|
find(".test-external-action").text(actual);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.set("content", ["red", "blue"]);
|
||||||
|
},
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
await this.get("subject").expand();
|
||||||
|
await this.get("subject").selectRowByValue("red");
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".test-external-action")
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
"red"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
componentTest("onDeselect", {
|
||||||
|
template:
|
||||||
|
"<div class='test-external-action'></div>{{single-select content=content onDeselect=(action externalAction)}}",
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
this.set("externalAction", actual => {
|
||||||
|
find(".test-external-action").text(actual);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.set("content", ["red", "blue"]);
|
||||||
|
},
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
await this.get("subject").expand();
|
||||||
|
await this.get("subject").selectRowByValue("red");
|
||||||
|
await this.get("subject").expand();
|
||||||
|
await this.get("subject").selectRowByValue("blue");
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".test-external-action")
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
"red"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user