UX: disable arrow up to edit if last message is not editable (#20729)
This commit is contained in:
parent
aa8eff5e16
commit
aeab38aff1
|
@ -896,17 +896,20 @@ export default class ChatLivePane extends Component {
|
|||
@action
|
||||
editLastMessageRequested() {
|
||||
const lastUserMessage = this.args.channel.messages.findLast(
|
||||
(message) =>
|
||||
message.user.id === this.currentUser.id &&
|
||||
!message.staged &&
|
||||
!message.error
|
||||
(message) => message.user.id === this.currentUser.id
|
||||
);
|
||||
|
||||
if (lastUserMessage) {
|
||||
if (!lastUserMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastUserMessage.staged || lastUserMessage.error) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.editingMessage = lastUserMessage;
|
||||
this._focusComposer();
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
setReplyTo(messageId) {
|
||||
|
|
|
@ -70,5 +70,19 @@ RSpec.describe "Shortcuts | chat composer", type: :system, js: true do
|
|||
|
||||
expect(page.find(".chat-composer-message-details")).to have_content(message_1.message)
|
||||
end
|
||||
|
||||
context "when last message is not editable" do
|
||||
after { page.driver.browser.network_conditions = { offline: false } }
|
||||
|
||||
it "does not edit a message" do
|
||||
chat.visit_channel(channel_1)
|
||||
page.driver.browser.network_conditions = { offline: true }
|
||||
channel_page.send_message("Hello world")
|
||||
|
||||
find(".chat-composer-input").send_keys(:arrow_up)
|
||||
|
||||
expect(page).to have_no_css(".chat-composer-message-details")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue