diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 142281ce..314889a5 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -156,6 +156,7 @@ const MarkdownTextInput = React.forwardRef( }, ref, ) => { + const compositionRef = useRef(false); const divRef = useRef(null); const currentlyFocusedField = useRef(null); const contentSelection = useRef(null); @@ -269,6 +270,12 @@ const MarkdownTextInput = React.forwardRef( return; } + if (compositionRef.current) { + updateTextColor(divRef.current, e.target.innerText); + compositionRef.current = false; + return; + } + let text = ''; const nativeEvent = e.nativeEvent as MarkdownNativeEvent; switch (nativeEvent.inputType) { @@ -514,6 +521,10 @@ const MarkdownTextInput = React.forwardRef( divRef.current.focus(); }, []); + const startComposition = useCallback(() => { + compositionRef.current = true; + }, []); + return ( // eslint-disable-next-line jsx-a11y/no-static-element-interactions
( autoCapitalize={autoCapitalize} className={className} onKeyDown={handleKeyPress} + onCompositionStart={startComposition} onKeyUp={updateSelection} onInput={handleOnChangeText} onSelect={handleSelectionChange}