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