diff --git a/.changeset/lovely-walls-knock.md b/.changeset/lovely-walls-knock.md new file mode 100644 index 0000000000..b949103856 --- /dev/null +++ b/.changeset/lovely-walls-knock.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Fixed a bug that resulted in doubly-input characters when using an IME. diff --git a/packages/slate-react/src/components/leaf.tsx b/packages/slate-react/src/components/leaf.tsx index 21e064af86..0d09ea99b4 100644 --- a/packages/slate-react/src/components/leaf.tsx +++ b/packages/slate-react/src/components/leaf.tsx @@ -4,6 +4,9 @@ import String from './string' import { PLACEHOLDER_SYMBOL } from '../utils/weak-maps' import { RenderLeafProps } from './editable' +// auto-incrementing key for String component, force it refresh to +// prevent inconsistent rendering by React with IME input +let keyForString = 0 /** * Individual leaves in a text node with unique formatting. */ @@ -43,7 +46,13 @@ const Leaf = (props: { }, [placeholderRef]) let children = ( - + ) if (leaf[PLACEHOLDER_SYMBOL]) {