diff --git a/src/components/Composer/index.tsx b/src/components/Composer/index.tsx index 43a100cf3c90..4bc54d13b056 100755 --- a/src/components/Composer/index.tsx +++ b/src/components/Composer/index.tsx @@ -118,11 +118,8 @@ function Composer( * Adds the cursor position to the selection change event. */ const addCursorPositionToSelectionChange = (event: NativeSyntheticEvent) => { - if (!isRendered) { - return; - } const webEvent = event as BaseSyntheticEvent; - if (shouldCalculateCaretPosition) { + if (shouldCalculateCaretPosition && isRendered) { // we do flushSync to make sure that the valueBeforeCaret is updated before we calculate the caret position to receive a proper position otherwise we will calculate position for the previous state flushSync(() => { setValueBeforeCaret(webEvent.target.value.slice(0, webEvent.nativeEvent.selection.start));