From bf1d65623cd484fa17e4de5e9083ecb5dfe7ab81 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 29 Jul 2019 11:31:22 +0100 Subject: [PATCH] Move history with alt up/down regardless of where selection is Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/rooms/MessageComposerInput.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index d182ed4205..ca25ada12d 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -1130,17 +1130,6 @@ export default class MessageComposerInput extends React.Component { onVerticalArrow = (e, up) => { if (e.ctrlKey || e.shiftKey || e.metaKey) return; - // selection must be collapsed - const selection = this.state.editorState.selection; - if (!selection.isCollapsed) return; - // and we must be at the edge of the document (up=start, down=end) - const document = this.state.editorState.document; - if (up) { - if (!selection.anchor.isAtStartOfNode(document)) return; - } else { - if (!selection.anchor.isAtEndOfNode(document)) return; - } - const shouldSelectHistory = e.altKey; const shouldEditLastMessage = !e.altKey && up && !RoomViewStore.getQuotingEvent(); @@ -1152,6 +1141,17 @@ export default class MessageComposerInput extends React.Component { e.preventDefault(); } } else if (shouldEditLastMessage) { + // selection must be collapsed + const selection = this.state.editorState.selection; + if (!selection.isCollapsed) return; + // and we must be at the edge of the document (up=start, down=end) + const document = this.state.editorState.document; + if (up) { + if (!selection.anchor.isAtStartOfNode(document)) return; + } else { + if (!selection.anchor.isAtEndOfNode(document)) return; + } + const editEvent = findEditableEvent(this.props.room, false); if (editEvent) { // We're selecting history, so prevent the key event from doing anything else