Skip to content

Commit a71f678

Browse files
committed
another attempt at #6803...
1 parent 3bf32e3 commit a71f678

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/packages/frontend/editors/slate/slate-react/plugin/react-editor.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ export const ReactEditor = {
166166
// it's very important to restore the selection to where it was before
167167
// focusing, since otherwise the selection is reset to the top of the document.
168168
Transforms.setSelection(editor, selection);
169+
// Critical to update the DOM selection ASAP, but not in same render loop (since that's too soon).
170+
// Note that useLayoutEffect is not quick enough and things get broken without this below. An example
171+
// is in virtualized mode when moving a list item down in a list.
172+
const { updateDOMSelection } = editor;
173+
if (updateDOMSelection != null) {
174+
window.requestAnimationFrame(updateDOMSelection);
175+
}
169176
}
170177
},
171178

0 commit comments

Comments
 (0)