Skip to content

Commit

Permalink
Fix getting curosr position while typing text
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Oct 3, 2024
1 parent a754fc4 commit 9c9c06a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/components/Composer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9c9c06a

Please sign in to comment.