From 17183c3ee64d59bc2c308710c659f86cb4fee724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ska=C5=82ka?= Date: Mon, 15 Apr 2024 16:59:43 +0200 Subject: [PATCH] Fix selection prop useEffect --- src/MarkdownTextInput.web.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 891b6b9c9..7779a6d2d 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -575,7 +575,9 @@ const MarkdownTextInput = React.forwardRef( } 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 whn typing + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [selection]); useEffect(() => { if (history.current?.history.length !== 0) {