FIX: cancel editing should clear the composer (#21011)
This commit is contained in:
parent
9d50e8189e
commit
79cacba948
plugins/chat
assets/javascripts/discourse/components
spec/system
|
@ -10,7 +10,7 @@
|
||||||
<ChatComposerMessageDetails
|
<ChatComposerMessageDetails
|
||||||
@message={{this.composerService.editingMessage}}
|
@message={{this.composerService.editingMessage}}
|
||||||
@icon="pencil-alt"
|
@icon="pencil-alt"
|
||||||
@action={{action "cancelEditing"}}
|
@action={{this.cancelEditing}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
@ -191,14 +191,12 @@ export default Component.extend(TextareaTextManipulation, {
|
||||||
this.paneService?.editLastMessageRequested();
|
this.paneService?.editLastMessageRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.keyCode === 27) {
|
if (event.key === "Escape") {
|
||||||
// keyCode for 'Escape'
|
|
||||||
if (this.composerService?.replyToMsg) {
|
if (this.composerService?.replyToMsg) {
|
||||||
this.set("value", "");
|
this.set("value", "");
|
||||||
this.composerService?.setReplyTo(null);
|
this.composerService?.setReplyTo(null);
|
||||||
return false;
|
return false;
|
||||||
} else if (this.composerService?.editingMessage) {
|
} else if (this.composerService?.editingMessage) {
|
||||||
this.set("value", "");
|
|
||||||
this.cancelEditing();
|
this.cancelEditing();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -719,6 +717,7 @@ export default Component.extend(TextareaTextManipulation, {
|
||||||
@action
|
@action
|
||||||
cancelEditing() {
|
cancelEditing() {
|
||||||
this.composerService?.cancelEditing();
|
this.composerService?.cancelEditing();
|
||||||
|
this.set("value", "");
|
||||||
this._focusTextArea({ ensureAtEnd: true, resizeTextarea: true });
|
this._focusTextArea({ ensureAtEnd: true, resizeTextarea: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@
|
||||||
{{#if (or @channel.isDraft @channel.isFollowing)}}
|
{{#if (or @channel.isDraft @channel.isFollowing)}}
|
||||||
<ChatComposer
|
<ChatComposer
|
||||||
@sendMessage={{this.sendMessage}}
|
@sendMessage={{this.sendMessage}}
|
||||||
@onCancelEditing={{this.cancelEditing}}
|
|
||||||
@chatChannel={{@channel}}
|
@chatChannel={{@channel}}
|
||||||
@composerService={{this.chatChannelComposer}}
|
@composerService={{this.chatChannelComposer}}
|
||||||
@paneService={{this.chatChannelPane}}
|
@paneService={{this.chatChannelPane}}
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
<ChatComposer
|
<ChatComposer
|
||||||
@sendMessage={{this.sendMessage}}
|
@sendMessage={{this.sendMessage}}
|
||||||
@onCancelEditing={{this.cancelEditing}}
|
|
||||||
@chatChannel={{this.channel}}
|
@chatChannel={{this.channel}}
|
||||||
@composerService={{this.chatChannelThreadComposer}}
|
@composerService={{this.chatChannelThreadComposer}}
|
||||||
@paneService={{this.chatChannelThreadPane}}
|
@paneService={{this.chatChannelThreadPane}}
|
||||||
|
|
|
@ -72,6 +72,18 @@ RSpec.describe "Chat composer", type: :system, js: true do
|
||||||
find(".chat-composer-input").send_keys(:escape)
|
find(".chat-composer-input").send_keys(:escape)
|
||||||
|
|
||||||
expect(page).to have_no_selector(".chat-composer-message-details .chat-reply__username")
|
expect(page).to have_no_selector(".chat-composer-message-details .chat-reply__username")
|
||||||
|
expect(find(".chat-composer-input").value).to eq("")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when closing edited message" do
|
||||||
|
it "cancels editing" do
|
||||||
|
chat.visit_channel(channel_1)
|
||||||
|
channel.edit_message(message_2)
|
||||||
|
find(".cancel-message-action").click
|
||||||
|
|
||||||
|
expect(page).to have_no_selector(".chat-composer-message-details .chat-reply__username")
|
||||||
|
expect(find(".chat-composer-input").value).to eq("")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue