(e: DragEvent)
| 314 | }; |
| 315 | |
| 316 | let onDrop = (e: DragEvent) => { |
| 317 | e.preventDefault(); |
| 318 | e.stopPropagation(); |
| 319 | // Track drop effect in global state for Chrome Android. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951 |
| 320 | // Android onDragEnd always returns "none" as its drop effect. |
| 321 | setGlobalDropEffect(state.dropEffect); |
| 322 | |
| 323 | if (typeof options.onDrop === 'function') { |
| 324 | let dropOperation = DROP_EFFECT_TO_DROP_OPERATION[state.dropEffect]; |
| 325 | let items = readFromDataTransfer(e.dataTransfer); |
| 326 | |
| 327 | let rect = (e.currentTarget as HTMLElement).getBoundingClientRect(); |
| 328 | let event: DropEvent = { |
| 329 | type: 'drop', |
| 330 | x: e.clientX - rect.x, |
| 331 | y: e.clientY - rect.y, |
| 332 | items, |
| 333 | dropOperation |
| 334 | }; |
| 335 | |
| 336 | options.onDrop(event); |
| 337 | } |
| 338 | |
| 339 | let dndStateSnapshot = {...globalDndState}; |
| 340 | state.dragOverElements.clear(); |
| 341 | fireDropExit(e); |
| 342 | clearTimeout(state.dropActivateTimer); |
| 343 | // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a |
| 344 | // RSP collection and thus we don't need to preserve the global drop effect |
| 345 | if (dndStateSnapshot.draggingCollectionRef == null) { |
| 346 | setGlobalDropEffect(undefined); |
| 347 | } else { |
| 348 | // Otherwise we need to preserve the global dnd state for onDragEnd's isInternal check. |
| 349 | // At the moment fireDropExit may clear dropCollectionRef (i.e. useDroppableCollection's provided onDropExit, required to clear dropCollectionRef when exiting a valid drop target) |
| 350 | setGlobalDnDState(dndStateSnapshot); |
| 351 | } |
| 352 | }; |
| 353 | |
| 354 | let onDropEnter = useEffectEvent((e: DropEnterEvent) => { |
| 355 | if (typeof options.onDropEnter === 'function') { |
nothing calls this directly
no test coverage detected