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|}}
|
||||
{{#if b.popupMenu}}
|
||||
{{toolbar-popup-menu-options
|
||||
onPopupMenuAction=onPopupMenuAction
|
||||
onSelect=onPopupMenuAction
|
||||
onExpand=(action b.action b)
|
||||
title=b.title
|
||||
headerIcon=b.icon
|
||||
|
|
|
@ -210,6 +210,10 @@ export default SelectKitComponent.extend({
|
|||
},
|
||||
|
||||
select(computedContentItem) {
|
||||
if (this.get("hasSelection")) {
|
||||
this.deselect(this.get("selection.value"));
|
||||
}
|
||||
|
||||
if (
|
||||
!computedContentItem ||
|
||||
computedContentItem.__sk_row_type === "noneRow"
|
||||
|
|
|
@ -12,10 +12,7 @@ export default DropdownSelectBoxComponent.extend({
|
|||
return `<h3>${title}</h3>`;
|
||||
},
|
||||
|
||||
mutateValue(value) {
|
||||
this.sendAction("onPopupMenuAction", value);
|
||||
this.setProperties({ value: null, highlighted: null });
|
||||
},
|
||||
autoHighlight() {},
|
||||
|
||||
computeContent(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(
|
||||
"Composer can toggle between reply and createTopic",
|
||||
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