Repository: adobe/react-spectrum
File: packages/@react-aria/dnd/src/DragManager.ts (TypeScript)

Code before:
      this.cancelEvent(e);
      return;
    }

    if (e.target !== this.dragTarget.element) {
      this.cancelEvent(e);
    }

    // If nothing is gaining focus, or e.relatedTarget is the window/document (JSDOM),
    // restore focus back to the current drop target if any, or the original drag target.
    if (!e.relatedTarget || !(e.relatedTarget instanceof HTMLElement)) {
      if (this.currentDropTarget) {
        this.currentDropTarget.element.focus();
      } else {
        this.dragTarget.element.focus();
      }
    }
  }

  onClick(e: MouseEvent) {
    this.cancelEvent(e);
    if (isVirtualClick(e) || this.isVirtualClick) {
      if (this.getCurrentActivateButton()?.contains(e.target as Node)) {
        this.activate();
        return;
      }

      if (e.target === this.dragTarget.element) {
        this.cancel();
        return;
      }

      let dropTarget = this.validDropTargets.find(target => target.element.contains(e.target as HTMLElement));
      if (dropTarget) {
        let item = dropItems.get(e.target as HTMLElement);
        this.setCurrentDropTarget(dropTarget, item);
        this.drop(item);
      }
    }
  }

  onPointerDown(e: PointerEvent) {
    // Android Talkback double tap has e.detail = 1 for onClick. Detect the virtual click in onPointerDown before onClick fires
    // so we can properly perform cancel and drop operations.
    this.cancelEvent(e);
    this.isVirtualClick = isVirtualPointerEvent(e);
  }

  cancelEvent(e: Event) {
    // Allow focusin and focusout on the drag target so focus ring works properly.
    if ((e.type === 'focusin' || e.type === 'focusout') && (e.target === this.dragTarget?.element || e.target === this.getCurrentActivateButton())) {

Review comment (suggestion):
In Android talkback, when I double tap when focused on the expand chevron while a drag session is active, the drop executes instead of expanding the target row. Not sure why, will need to dig when I can actually connect to a my locally hosted storybook rather than the built one

Code after:
      this.cancelEvent(e);
      return;
    }

    if (e.target !== this.dragTarget.element) {
      this.cancelEvent(e);
    }

    // If nothing is gaining focus, or e.relatedTarget is the window/document (JSDOM),
    // restore focus back to the current drop target if any, or the original drag target.
    if (!e.relatedTarget || !(e.relatedTarget instanceof HTMLElement)) {
      if (this.currentDropTarget) {
        this.currentDropTarget.element.focus();
      } else {
        this.dragTarget.element.focus();
      }
    }
  }

  onClick(e: MouseEvent) {
    this.cancelEvent(e);
    if (isVirtualClick(e) || this.isVirtualClick) {
      let dropElements = dropItems.values();
      let item = [...dropElements].find(item => item.element === e.target as HTMLElement || item.activateButtonRef?.current?.contains(e.target as HTMLElement));
      let dropTarget = this.validDropTargets.find(target => target.element.contains(e.target as HTMLElement));
      let activateButton = item?.activateButtonRef?.current ?? dropTarget?.activateButtonRef?.current;
      if (activateButton?.contains(e.target as HTMLElement) && dropTarget) {
        this.activate(dropTarget, item);
        return;
      }

      if (e.target === this.dragTarget.element) {
        this.cancel();
        return;
      }

      if (dropTarget) {
        this.setCurrentDropTarget(dropTarget, item);
        this.drop(item);
      }
    }
  }

  onPointerDown(e: PointerEvent) {
    // Android Talkback double tap has e.detail = 1 for onClick. Detect the virtual click in onPointerDown before onClick fires
    // so we can properly perform cancel and drop operations.
    this.cancelEvent(e);
    this.isVirtualClick = isVirtualPointerEvent(e);
  }

  cancelEvent(e: Event) {