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:
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(
|
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
|
||||||
|
Reference in New Issue
Block a user