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

Method previous

packages/react-aria/src/dnd/DragManager.ts:492–525  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

490 }
491
492 previous(): void {
493 // let activateButton = this.getCurrentActivateButton();
494 // if (activateButton && document.activeElement === activateButton) {
495 // let target = this.currentDropItem ?? this.currentDropTarget;
496 // if (target) {
497 // target.element.focus();
498 // return;
499 // }
500 // }
501
502 if (!this.currentDropTarget) {
503 this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);
504 return;
505 }
506
507 let index = this.validDropTargets.indexOf(this.currentDropTarget);
508 if (index < 0) {
509 this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);
510 return;
511 }
512
513 // If we've reached the start of the valid drop targets, cycle back to the original drag target.
514 // This lets the user cancel the drag in case they don't have an Escape key (e.g. iPad keyboard case).
515 if (index === 0) {
516 if (!this.dragTarget.element.closest('[aria-hidden="true"], [inert]')) {
517 this.setCurrentDropTarget(null);
518 this.dragTarget.element.focus();
519 } else {
520 this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);
521 }
522 } else {
523 this.setCurrentDropTarget(this.validDropTargets[index - 1]);
524 }
525 }
526
527 findNearestDropTarget(): number {
528 let dragTargetRect = this.dragTarget.element.getBoundingClientRect();

Callers 1

onKeyDownMethod · 0.95

Calls 2

setCurrentDropTargetMethod · 0.95
focusMethod · 0.80

Tested by

no test coverage detected