mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-21 14:41:23 +02:00
fix isDraggingInternally reset logic (#4828)
This commit is contained in:
5
.changeset/dirty-bobcats-marry.md
Normal file
5
.changeset/dirty-bobcats-marry.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Reset isDraggingInternally onDragEnd and onDrop even if the event is handled by the editable handler
|
@@ -970,8 +970,6 @@ export const Editable = (props: EditableProps) => {
|
|||||||
at: draggedRange,
|
at: draggedRange,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
state.isDraggingInternally = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactEditor.insertData(editor, data)
|
ReactEditor.insertData(editor, data)
|
||||||
@@ -982,22 +980,26 @@ export const Editable = (props: EditableProps) => {
|
|||||||
ReactEditor.focus(editor)
|
ReactEditor.focus(editor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.isDraggingInternally = false
|
||||||
},
|
},
|
||||||
[readOnly, attributes.onDrop]
|
[readOnly, attributes.onDrop]
|
||||||
)}
|
)}
|
||||||
onDragEnd={useCallback(
|
onDragEnd={useCallback(
|
||||||
(event: React.DragEvent<HTMLDivElement>) => {
|
(event: React.DragEvent<HTMLDivElement>) => {
|
||||||
// When dropping on a different droppable element than the current editor,
|
|
||||||
// `onDrop` is not called. So we need to clean up in `onDragEnd` instead.
|
|
||||||
// Note: `onDragEnd` is only called when `onDrop` is not called
|
|
||||||
if (
|
if (
|
||||||
!readOnly &&
|
!readOnly &&
|
||||||
state.isDraggingInternally &&
|
state.isDraggingInternally &&
|
||||||
hasTarget(editor, event.target) &&
|
attributes.onDragEnd &&
|
||||||
!isEventHandled(event, attributes.onDragEnd)
|
hasTarget(editor, event.target)
|
||||||
) {
|
) {
|
||||||
state.isDraggingInternally = false
|
attributes.onDragEnd(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When dropping on a different droppable element than the current editor,
|
||||||
|
// `onDrop` is not called. So we need to clean up in `onDragEnd` instead.
|
||||||
|
// Note: `onDragEnd` is only called when `onDrop` is not called
|
||||||
|
state.isDraggingInternally = false
|
||||||
},
|
},
|
||||||
[readOnly, attributes.onDragEnd]
|
[readOnly, attributes.onDragEnd]
|
||||||
)}
|
)}
|
||||||
|
Reference in New Issue
Block a user