Skip to content

Commit 358680d

Browse files
authored
fix: Update dnd to handle inert (#8560)
1 parent 514384f commit 358680d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/@react-aria/dnd/src/DragManager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class DragSession {
410410
...visibleDropTargets.flatMap(target => target.activateButtonRef?.current ? [target.element, target.activateButtonRef?.current] : [target.element])
411411
], {shouldUseInert: true});
412412

413-
this.mutationObserver.observe(document.body, {subtree: true, attributes: true, attributeFilter: ['aria-hidden']});
413+
this.mutationObserver.observe(document.body, {subtree: true, attributes: true, attributeFilter: ['aria-hidden', 'inert']});
414414
}
415415

416416
next(): void {
@@ -437,7 +437,7 @@ class DragSession {
437437
// If we've reached the end of the valid drop targets, cycle back to the original drag target.
438438
// This lets the user cancel the drag in case they don't have an Escape key (e.g. iPad keyboard case).
439439
if (index === this.validDropTargets.length - 1) {
440-
if (!this.dragTarget.element.closest('[aria-hidden="true"]')) {
440+
if (!this.dragTarget.element.closest('[aria-hidden="true"], [inert]')) {
441441
this.setCurrentDropTarget(null);
442442
this.dragTarget.element.focus();
443443
} else {
@@ -472,7 +472,7 @@ class DragSession {
472472
// If we've reached the start of the valid drop targets, cycle back to the original drag target.
473473
// This lets the user cancel the drag in case they don't have an Escape key (e.g. iPad keyboard case).
474474
if (index === 0) {
475-
if (!this.dragTarget.element.closest('[aria-hidden="true"]')) {
475+
if (!this.dragTarget.element.closest('[aria-hidden="true"], [inert]')) {
476476
this.setCurrentDropTarget(null);
477477
this.dragTarget.element.focus();
478478
} else {
@@ -579,7 +579,7 @@ class DragSession {
579579
cancel(): void {
580580
this.setCurrentDropTarget(null);
581581
this.end();
582-
if (!this.dragTarget.element.closest('[aria-hidden="true"]')) {
582+
if (!this.dragTarget.element.closest('[aria-hidden="true"], [inert]')) {
583583
this.dragTarget.element.focus();
584584
}
585585

@@ -640,7 +640,7 @@ class DragSession {
640640
function findValidDropTargets(options: DragTarget) {
641641
let types = getTypes(options.items);
642642
return [...dropTargets.values()].filter(target => {
643-
if (target.element.closest('[aria-hidden="true"]')) {
643+
if (target.element.closest('[aria-hidden="true"], [inert]')) {
644644
return false;
645645
}
646646

0 commit comments

Comments
 (0)