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:
parent
680fa9cd34
commit
836f660054
5
.changeset/red-hats-guess.md
Normal file
5
.changeset/red-hats-guess.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate-react': patch
|
||||
---
|
||||
|
||||
Add checks to Editable selection change handler to avoid errors
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user