From 984988c88b816ea79c40bb3042610f7acad76082 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 19 Jul 2019 18:33:09 -0300 Subject: [PATCH] fix arrow up to edit --- app/ui/client/lib/chatMessages.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/ui/client/lib/chatMessages.js b/app/ui/client/lib/chatMessages.js index eb2422eb1f16..b96f9d432256 100644 --- a/app/ui/client/lib/chatMessages.js +++ b/app/ui/client/lib/chatMessages.js @@ -138,18 +138,22 @@ export class ChatMessages { toPrevMessage() { const { element } = this.editing; - if (element) { - let previous; - for (previous = element.previousElementSibling; previous; previous = previous.previousElementSibling) { - if (previous.matches('.own:not(.system)')) { - break; - } + if (!element) { + const messages = Array.from(this.wrapper.querySelectorAll('.own:not(.system)')); + const message = messages.pop(); + return message && this.edit(message, false); + } + + for ( + let previous = element.previousElementSibling; + previous; + previous = previous.previousElementSibling + ) { + if (previous.matches('.own:not(.system)')) { + return this.edit(previous, false); } - - previous ? this.edit(previous, false) : this.clearEditing(); - } else { - this.edit(this.wrapper.querySelector('.own:not(.system):last-child'), false); } + this.clearEditing(); } toNextMessage() {