MCPcopy Index your code
hub / github.com/adobe/react-spectrum / drop

Method drop

packages/react-aria/src/dnd/DragManager.ts:642–684  ·  view source on GitHub ↗
(item?: DroppableItem)

Source from the content-addressed store, hash-verified

640 }
641
642 drop(item?: DroppableItem): void {
643 if (!this.currentDropTarget) {
644 this.cancel();
645 return;
646 }
647
648 if (typeof item?.getDropOperation === 'function') {
649 let types = getTypes(this.dragTarget.items);
650 this.dropOperation = item.getDropOperation(types, this.dragTarget.allowedDropOperations);
651 } else if (typeof this.currentDropTarget.getDropOperation === 'function') {
652 let types = getTypes(this.dragTarget.items);
653 this.dropOperation = this.currentDropTarget.getDropOperation(
654 types,
655 this.dragTarget.allowedDropOperations
656 );
657 } else {
658 // TODO: show menu ??
659 this.dropOperation = this.dragTarget.allowedDropOperations[0];
660 }
661
662 if (typeof this.currentDropTarget.onDrop === 'function') {
663 let items: DropItem[] = this.dragTarget.items.map(item => ({
664 kind: 'text',
665 types: new Set(Object.keys(item)),
666 getText: (type: string) => Promise.resolve(item[type])
667 }));
668
669 let rect = this.currentDropTarget.element.getBoundingClientRect();
670 this.currentDropTarget.onDrop(
671 {
672 type: 'drop',
673 x: rect.left + rect.width / 2,
674 y: rect.top + rect.height / 2,
675 items,
676 dropOperation: this.dropOperation
677 },
678 item?.target ?? null
679 );
680 }
681
682 this.end();
683 announce(this.stringFormatter.format('dropComplete'));
684 }
685
686 activate(dropTarget: DropTarget | null, dropItem: DroppableItem | null | undefined): void {
687 if (dropTarget && typeof dropTarget.onDropActivate === 'function') {

Callers 2

onKeyUpMethod · 0.95
onClickMethod · 0.95

Calls 6

cancelMethod · 0.95
endMethod · 0.95
getTypesFunction · 0.90
announceFunction · 0.90
getDropOperationMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected