1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 20:40:19 +02:00

fix: cancel debounced listeners in Editable (#5322)

* fix: cancel debounced listeners in Editable

* fix: add change set
This commit is contained in:
Ed Hager
2023-02-27 18:28:13 -06:00
committed by GitHub
parent 680fa9cd34
commit 836f660054
2 changed files with 9 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
Add checks to Editable selection change handler to avoid errors

View File

@@ -701,6 +701,9 @@ export const Editable = (props: EditableProps) => {
const callbackRef = useCallback( const callbackRef = useCallback(
node => { node => {
if (node == null) { if (node == null) {
onDOMSelectionChange.cancel()
scheduleOnDOMSelectionChange.cancel()
EDITOR_TO_ELEMENT.delete(editor) EDITOR_TO_ELEMENT.delete(editor)
NODE_TO_ELEMENT.delete(editor) NODE_TO_ELEMENT.delete(editor)
@@ -721,7 +724,7 @@ export const Editable = (props: EditableProps) => {
ref.current = node ref.current = node
}, },
[ref, onDOMBeforeInput] [ref, onDOMBeforeInput, onDOMSelectionChange, scheduleOnDOMSelectionChange]
) )
// Attach a native DOM event handler for `selectionchange`, because React's // Attach a native DOM event handler for `selectionchange`, because React's