UX: disable arrow up to edit if last message is not editable (#20729)

This commit is contained in:
Joffrey JAFFEUX 2023-03-17 23:08:10 +01:00 committed by GitHub
parent aa8eff5e16
commit aeab38aff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 7 deletions

View File

@ -896,17 +896,20 @@ export default class ChatLivePane extends Component {
@action @action
editLastMessageRequested() { editLastMessageRequested() {
const lastUserMessage = this.args.channel.messages.findLast( const lastUserMessage = this.args.channel.messages.findLast(
(message) => (message) => message.user.id === this.currentUser.id
message.user.id === this.currentUser.id &&
!message.staged &&
!message.error
); );
if (lastUserMessage) { if (!lastUserMessage) {
return;
}
if (lastUserMessage.staged || lastUserMessage.error) {
return;
}
this.editingMessage = lastUserMessage; this.editingMessage = lastUserMessage;
this._focusComposer(); this._focusComposer();
} }
}
@action @action
setReplyTo(messageId) { setReplyTo(messageId) {

View File

@ -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) expect(page.find(".chat-composer-message-details")).to have_content(message_1.message)
end 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
end end