From d696373bc283f475a9e7921055990d7f313ffa37 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 28 Jun 2017 15:29:07 +0100 Subject: [PATCH] Fix issue where the cursor is put at the start of selected history item Leading to strange behaviour when selecting all and deleting it. Fixes https://github.com/vector-im/riot-web/issues/4450 --- src/components/views/rooms/MessageComposerInput.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 90ac905553..c5fab8242e 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -568,6 +568,14 @@ export default class MessageComposerInput extends React.Component { 'insert-characters', ); + // Move selection to the end of the selected history + let newSelection = SelectionState.createEmpty(newContent.getLastBlock().getKey()); + newSelection = newSelection.merge({ + focusOffset: newContent.getLastBlock().getLength(), + anchorOffset: newContent.getLastBlock().getLength(), + }); + editorState = EditorState.forceSelection(editorState, newSelection); + this.setState({editorState}); return true; }