| 604 | } |
| 605 | |
| 606 | end(): void { |
| 607 | this.teardown(); |
| 608 | endDragging(); |
| 609 | |
| 610 | if (typeof this.dragTarget.onDragEnd === 'function') { |
| 611 | let target = |
| 612 | this.currentDropTarget && this.dropOperation !== 'cancel' |
| 613 | ? this.currentDropTarget |
| 614 | : this.dragTarget; |
| 615 | let rect = target.element.getBoundingClientRect(); |
| 616 | this.dragTarget.onDragEnd({ |
| 617 | type: 'dragend', |
| 618 | x: rect.x + rect.width / 2, |
| 619 | y: rect.y + rect.height / 2, |
| 620 | dropOperation: this.dropOperation || 'cancel' |
| 621 | }); |
| 622 | } |
| 623 | |
| 624 | if (this.currentDropTarget && !this.currentDropTarget.preventFocusOnDrop) { |
| 625 | // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent). |
| 626 | // This corrects state such as whether focus ring should appear. |
| 627 | // useDroppableCollection handles this itself, so this is only for standalone drop zones. |
| 628 | getActiveElement()?.dispatchEvent(new FocusEvent('focusin', {bubbles: true})); |
| 629 | } |
| 630 | |
| 631 | this.setCurrentDropTarget(null); |
| 632 | } |
| 633 | |
| 634 | cancel(): void { |
| 635 | this.setCurrentDropTarget(null); |