From 03c37821f6784b350a1160db2d15bb2c192b3d81 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 15 Jun 2019 15:10:34 +0100 Subject: [PATCH] clean up onVerticalArrow Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/rooms/MessageComposerInput.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 09dd12e494..7684e1dced 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -1206,15 +1206,22 @@ export default class MessageComposerInput extends React.Component { onVerticalArrow = (e, up) => { if (e.ctrlKey || e.shiftKey || e.metaKey) return; - // Select history - const selection = this.state.editorState.selection; + if (e.altKey) { + // Try select composer history + const selected = this.selectHistory(up); + if (selected) { + // We're selecting history, so prevent the key event from doing anything else + e.preventDefault(); + } + } else if (!e.altKey && up) { + // Try edit the latest message + const selection = this.state.editorState.selection; - // selection must be collapsed - if (!selection.isCollapsed) return; - const document = this.state.editorState.document; + // selection must be collapsed + if (!selection.isCollapsed) return; + const document = this.state.editorState.document; - // and we must be at the edge of the document (up=start, down=end) - if (up) { + // and we must be at the edge of the document (up=start, down=end) if (!selection.anchor.isAtStartOfNode(document)) return; if (!e.altKey) { @@ -1227,15 +1234,8 @@ export default class MessageComposerInput extends React.Component { event: editEvent, }); } - return; } } - - const selected = this.selectHistory(up); - if (selected) { - // We're selecting history, so prevent the key event from doing anything else - e.preventDefault(); - } }; selectHistory = async (up) => {