Skip to content

Commit

Permalink
Diacritics fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszGrajdek authored Mar 6, 2024
1 parent 831826d commit 8504e9b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
},
ref,
) => {
const compositionRef = useRef<boolean>(false);
const divRef = useRef<HTMLDivElement | null>(null);
const currentlyFocusedField = useRef<HTMLDivElement | null>(null);
const contentSelection = useRef<Selection | null>(null);
Expand Down Expand Up @@ -269,6 +270,12 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
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) {
Expand Down Expand Up @@ -514,6 +521,10 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
divRef.current.focus();
}, []);

const startComposition = useCallback(() => {
compositionRef.current = true;
}, []);

return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div
Expand All @@ -529,6 +540,7 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
autoCapitalize={autoCapitalize}
className={className}
onKeyDown={handleKeyPress}
onCompositionStart={startComposition}
onKeyUp={updateSelection}
onInput={handleOnChangeText}
onSelect={handleSelectionChange}
Expand Down

0 comments on commit 8504e9b

Please sign in to comment.