MCPcopy Create free account
hub / github.com/adobe/react-spectrum / onDragEnd

Function onDragEnd

packages/react-aria/src/dnd/useDrag.ts:255–279  ·  view source on GitHub ↗
(e: DragEvent)

Source from the content-addressed store, hash-verified

253 };
254
255 let onDragEnd = (e: DragEvent) => {
256 // Prevent the drag event from propagating to any parent draggables
257 e.stopPropagation();
258
259 if (typeof options.onDragEnd === 'function') {
260 let event: DragEndEvent = {
261 type: 'dragend',
262 x: e.clientX,
263 y: e.clientY,
264 dropOperation: DROP_EFFECT_TO_DROP_OPERATION[e.dataTransfer.dropEffect]
265 };
266
267 // Chrome Android always returns none as its dropEffect so we use the drop effect set in useDrop via
268 // onDragEnter/onDragOver instead. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951
269 if (globalDropEffect) {
270 event.dropOperation = DROP_EFFECT_TO_DROP_OPERATION[globalDropEffect];
271 }
272 options.onDragEnd(event);
273 }
274
275 setDragging(null);
276 removeAllGlobalListeners();
277 setGlobalAllowedDropOperations(DROP_OPERATION.none);
278 setGlobalDropEffect(undefined);
279 };
280
281 // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
282 // In this case, we need to manually call onDragEnd on cleanup

Callers 1

endDragFunction · 0.50

Calls 3

setGlobalDropEffectFunction · 0.90
setDraggingFunction · 0.70

Tested by

no test coverage detected