Skip to content

Commit

Permalink
Fix selection prop useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Apr 15, 2024
1 parent 7b19778 commit a6dc9d0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,9 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
}
CursorUtils.setCursorPosition(divRef.current, selection.start, selection.end);
updateSelection(null, {start: selection.start, end: selection.end || selection.start});
}, [selection, updateSelection]);
// we need to update the selection only when the selection prop changes, so it won't interfere with updating cursor position when typing
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selection]);

useEffect(() => {
if (history.current?.history.length !== 0) {
Expand Down

0 comments on commit a6dc9d0

Please sign in to comment.