1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-17 13:38:37 +01: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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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(
node => {
if (node == null) {
onDOMSelectionChange.cancel()
scheduleOnDOMSelectionChange.cancel()
EDITOR_TO_ELEMENT.delete(editor)
NODE_TO_ELEMENT.delete(editor)
@ -721,7 +724,7 @@ export const Editable = (props: EditableProps) => {
ref.current = node
},
[ref, onDOMBeforeInput]
[ref, onDOMBeforeInput, onDOMSelectionChange, scheduleOnDOMSelectionChange]
)
// Attach a native DOM event handler for `selectionchange`, because React's