Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diacritics fix #210

Merged
merged 6 commits into from
Mar 6, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 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 | null>(null);
BartoszGrajdek marked this conversation as resolved.
Show resolved Hide resolved
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,11 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
return;
}

if (compositionRef.current) {
compositionRef.current = false;
return;
}

let text = '';
const nativeEvent = e.nativeEvent as MarkdownNativeEvent;
switch (nativeEvent.inputType) {
Expand Down Expand Up @@ -514,6 +520,10 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
divRef.current.focus();
}, []);

const startComposition = () => {
compositionRef.current = true;
};
BartoszGrajdek marked this conversation as resolved.
Show resolved Hide resolved

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