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:
5
.changeset/strong-humans-taste.md
Normal file
5
.changeset/strong-humans-taste.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate-dom': patch
|
||||
---
|
||||
|
||||
Do not retry focusing editor after it has been unmounted
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user