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:
Joffrey JAFFEUX 2018-09-18 11:31:23 +02:00 committed by GitHub
parent fadcd36f92
commit a713c0d366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 5 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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 => {

View File

@ -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"
);
}
});