From 372fa29ad31820b8a96c221bffb222634310cfd9 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 3 Jul 2018 23:36:59 +0100 Subject: [PATCH] take edge into consideration when moving focus region on arrow keys fixes: >Pressing right when the caret is immediately left of some entity (pill, emojione emoji, etc..) causes the caret to jump to the left of the next entity (or end of the message if there are no more entities) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> (cherry picked from commit 0982617) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/MessageComposerInput.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index f5b22fd481..7ccee3ab16 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -449,13 +449,13 @@ export default class MessageComposerInput extends React.Component { if (this.direction !== '') { const focusedNode = editorState.focusInline || editorState.focusText; if (focusedNode.isVoid) { + const edge = this.direction === 'Previous' ? 'End' : 'Start'; if (editorState.isCollapsed) { - change = change[`collapseToEndOf${ this.direction }Text`](); - } - else { + change = change[`collapseTo${ edge }Of${ this.direction }Text`](); + } else { const block = this.direction === 'Previous' ? editorState.previousText : editorState.nextText; if (block) { - change = change.moveFocusToEndOf(block) + change = change[`moveFocusTo${ edge }Of`](block); } } editorState = change.value;