1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-19 05:31:56 +02:00

Check if editor is still mounted before trying to focus (#5916)

* Check if editor is still mounted before trying to focus

* Add changeset

---------

Co-authored-by: Raffael Wannenmacher <raffael.wannenmacher@tx.group>
This commit is contained in:
Raffael
2025-07-11 01:31:24 +02:00
committed by GitHub
parent ef76eb46e0
commit f2ea1e1e3a
2 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-dom': patch
---
Do not retry focusing editor after it has been unmounted

View File

@@ -422,6 +422,12 @@ export const DOMEditor: DOMEditorInterface = {
return
}
// Return if no dom node is associated with the editor, which means the editor is not yet mounted
// or has been unmounted. This can happen especially, while retrying to focus the editor.
if (!EDITOR_TO_ELEMENT.get(editor)) {
return
}
// Retry setting focus if the editor has pending operations.
// The DOM (selection) is unstable while changes are applied.
// Retry until retries are exhausted or editor is focused.