FIX: Switching composer action does not refresh composer actions content (#9791)
This commit is contained in:
parent
6b04760572
commit
7f07c513a7
|
@ -16,10 +16,12 @@ import { isEmpty } from "@ember/utils";
|
||||||
// Component can get destroyed and lose state
|
// Component can get destroyed and lose state
|
||||||
let _topicSnapshot = null;
|
let _topicSnapshot = null;
|
||||||
let _postSnapshot = null;
|
let _postSnapshot = null;
|
||||||
|
let _actionSnapshot = null;
|
||||||
|
|
||||||
export function _clearSnapshots() {
|
export function _clearSnapshots() {
|
||||||
_topicSnapshot = null;
|
_topicSnapshot = null;
|
||||||
_postSnapshot = null;
|
_postSnapshot = null;
|
||||||
|
_actionSnapshot = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DropdownSelectBoxComponent.extend({
|
export default DropdownSelectBoxComponent.extend({
|
||||||
|
@ -50,6 +52,7 @@ export default DropdownSelectBoxComponent.extend({
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
let changeContent = false;
|
||||||
|
|
||||||
// if we change topic we want to change both snapshots
|
// if we change topic we want to change both snapshots
|
||||||
if (
|
if (
|
||||||
|
@ -58,18 +61,25 @@ export default DropdownSelectBoxComponent.extend({
|
||||||
) {
|
) {
|
||||||
_topicSnapshot = this.topic;
|
_topicSnapshot = this.topic;
|
||||||
_postSnapshot = this.post;
|
_postSnapshot = this.post;
|
||||||
this.contentChanged();
|
changeContent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we hit reply on a different post we want to change postSnapshot
|
// if we hit reply on a different post we want to change postSnapshot
|
||||||
if (this.post && (!_postSnapshot || this.post.id !== _postSnapshot.id)) {
|
if (this.post && (!_postSnapshot || this.post.id !== _postSnapshot.id)) {
|
||||||
_postSnapshot = this.post;
|
_postSnapshot = this.post;
|
||||||
|
changeContent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.action !== _actionSnapshot) {
|
||||||
|
_actionSnapshot = this.action;
|
||||||
|
changeContent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changeContent) {
|
||||||
this.contentChanged();
|
this.contentChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(this.content)) {
|
this.set("selectKit.isHidden", isEmpty(this.content));
|
||||||
this.set("selectKit.isHidden", true);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
modifySelection() {
|
modifySelection() {
|
||||||
|
|
|
@ -148,12 +148,18 @@ QUnit.test("reply_as_new_topic without a new_topic draft", async assert => {
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("hide component if no content", async assert => {
|
QUnit.test("hide component if no content", async assert => {
|
||||||
const composerActions = selectKit(".composer-actions");
|
await visit("/");
|
||||||
|
await click("button#create-topic");
|
||||||
|
|
||||||
await visit("/u/eviltrout/messages");
|
const composerActions = selectKit(".composer-actions");
|
||||||
await click(".new-private-message");
|
await composerActions.expand();
|
||||||
|
await composerActions.selectRowByValue("reply_as_private_message");
|
||||||
|
|
||||||
assert.ok(composerActions.el().hasClass("is-hidden"));
|
assert.ok(composerActions.el().hasClass("is-hidden"));
|
||||||
|
|
||||||
|
await click("button#create-topic");
|
||||||
|
await composerActions.expand();
|
||||||
|
assert.equal(composerActions.rows().length, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("interactions", async assert => {
|
QUnit.test("interactions", async assert => {
|
||||||
|
|
Loading…
Reference in New Issue