From b5bfc3e2bf121ca72ac31c0cf49dd2ee75ed01f7 Mon Sep 17 00:00:00 2001 From: Nikhil Vats Date: Fri, 18 Aug 2023 10:05:22 +0530 Subject: [PATCH] Fix cursor shifting to end while editing messages --- src/components/Composer/index.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index abb1addceb5b..739d6ff3ab9c 100755 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -199,20 +199,22 @@ function Composer({ setValueBeforeCaret(event.target.value.slice(0, event.nativeEvent.selection.start)); setCaretContent(getNextChars(value, event.nativeEvent.selection.start)); }); + const selectionValue = { + start: event.nativeEvent.selection.start, + end: event.nativeEvent.selection.end, + positionX: textRef.current.offsetLeft - CONST.SPACE_CHARACTER_WIDTH, + positionY: textRef.current.offsetTop, + }; + onSelectionChange({ + nativeEvent: { + selection: selectionValue, + }, + }); + setSelection(selectionValue); + } else { + onSelectionChange(event); + setSelection(event.nativeEvent.selection); } - - const selectionValue = { - start: event.nativeEvent.selection.start, - end: event.nativeEvent.selection.end, - positionX: textRef.current.offsetLeft - CONST.SPACE_CHARACTER_WIDTH, - positionY: textRef.current.offsetTop, - }; - onSelectionChange({ - nativeEvent: { - selection: selectionValue, - }, - }); - setSelection(selectionValue); }; /**