From 9c9c06a7fd6e8a61323c1c3e48daf192d0beae86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ska=C5=82ka?= Date: Thu, 3 Oct 2024 12:28:23 +0200 Subject: [PATCH] Fix getting curosr position while typing text --- src/components/Composer/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/Composer/index.tsx b/src/components/Composer/index.tsx index 46c2b01f21af..c71159d8f410 100755 --- a/src/components/Composer/index.tsx +++ b/src/components/Composer/index.tsx @@ -92,8 +92,7 @@ function Composer( if (shouldCalculateCaretPosition && isRendered && sel) { const range = sel.getRangeAt(0).cloneRange(); range.collapse(true); - const currentElement = (range.startContainer.nodeType === Node.TEXT_NODE ? range.startContainer.parentElement : range.startContainer) as HTMLElement; - const rect = currentElement.getClientRects()[0]; + const rect = range.getClientRects()[0] || range.startContainer.parentElement?.getClientRects()[0]; const containerRect = textInput.current?.getBoundingClientRect(); let x = 0;