Skip to content

Commit

Permalink
Refactor if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
QichenZhu committed Jan 16, 2025
1 parent 961ac17 commit 9784a69
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 9784a69

Please sign in to comment.