Fix Slate crash after inserting emoji from picker/autocomplete
This commit is contained in:
@@ -82,13 +82,21 @@ function RenderEmoticonElement({
|
||||
const selected = useSelected();
|
||||
const focused = useFocused();
|
||||
|
||||
// Void inline: attributes + contentEditable={false} on the same root, children
|
||||
// as a sibling of the visual (not nested inside another non-editable span).
|
||||
// Nesting {children} under an inner contentEditable={false} breaks Slate's
|
||||
// DOM↔node map and crashes ReactEditor.focus after insert.
|
||||
return (
|
||||
<span className={css.EmoticonBase} {...attributes}>
|
||||
<span
|
||||
{...attributes}
|
||||
contentEditable={false}
|
||||
className={css.EmoticonBase}
|
||||
style={{ userSelect: 'none' }}
|
||||
>
|
||||
<span
|
||||
className={css.Emoticon({
|
||||
focus: selected && focused,
|
||||
})}
|
||||
contentEditable={false}
|
||||
>
|
||||
{element.key.startsWith('mxc://') ? (
|
||||
<img
|
||||
@@ -99,8 +107,8 @@ function RenderEmoticonElement({
|
||||
) : (
|
||||
element.key
|
||||
)}
|
||||
{children}
|
||||
</span>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user