From 9784a69536b7b4d1c4d24c710ad041da27c95275 Mon Sep 17 00:00:00 2001 From: QichenZhu <57348009+QichenZhu@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:55:59 +1300 Subject: [PATCH] Refactor if condition --- src/MarkdownTextInput.web.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 4b2bb011..ca0f7859 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -350,6 +350,7 @@ const MarkdownTextInput = React.forwardRef<MarkdownTextInput, MarkdownTextInputP } const nativeEvent = e.nativeEvent as MarkdownNativeEvent; const inputType = nativeEvent.inputType; + const isComposing = isEventComposing(nativeEvent); updateTextColor(divRef.current, e.target.textContent ?? ''); const previousText = divRef.current.value; @@ -371,7 +372,7 @@ const MarkdownTextInput = React.forwardRef<MarkdownTextInput, MarkdownTextInputP ? Math.max(contentSelection.current.start, 0) // Don't move the caret when deleting forward with no characters selected : Math.max(Math.max(contentSelection.current.end, 0) + (parsedText.length - previousText.length), 0); - if (isEventComposing(nativeEvent)) { + if (isComposing) { updateTextColor(divRef.current, parsedText); updateSelection(e, { start: newCursorPosition,