Skip to content

Commit b19994e

Browse files
author
Raffael Wannenmacher
committed
Add comments
1 parent 08db3b7 commit b19994e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/dnd/src/DndPlugin.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,20 @@ export const DndPlugin = createTPlatePlugin<DndConfig>({
8888
useHooks: ({ setOption }) => {
8989
const handleDocumentDragLeave = useCallback(
9090
(e: DragEvent) => {
91+
// This event fires for every element that receives a drag leave event. If `clientX` and `clientY` are both 0,
92+
// it means the drag has left the viewport. Needed, if the drag did not start inside the editor, but for example
93+
// by dragging a file from the filesystem
9194
if (!e.clientX && !e.clientY) {
9295
setOption('dropTarget', undefined);
9396
}
9497
},
9598
[setOption]
9699
);
97100

101+
// We listen for the drop event on the document and not only inside the editor, because we want to
102+
// remove the dropTarget, and therefore hide the drop line, also when the drop happened outside of
103+
// the editor. Needed, if the drag did not start inside the editor, but for example by dragging a
104+
// file from the filesystem
98105
const handleDocumentDrop = useCallback(() => {
99106
setOption('_isOver', false);
100107
setOption('dropTarget', undefined);

0 commit comments

Comments
 (0)