@@ -14,7 +14,7 @@ import {announce} from '@react-aria/live-announcer';
1414import { ariaHideOutside } from '@react-aria/overlays' ;
1515import { DragEndEvent , DragItem , DropActivateEvent , DropEnterEvent , DropEvent , DropExitEvent , DropItem , DropOperation , DropTarget as DroppableCollectionTarget , FocusableElement } from '@react-types/shared' ;
1616import { getDragModality , getTypes } from './utils' ;
17- import { isVirtualClick , isVirtualPointerEvent } from '@react-aria/utils' ;
17+ import { isVirtualClick , isVirtualPointerEvent , nodeContains } from '@react-aria/utils' ;
1818import type { LocalizedStringFormatter } from '@internationalized/string' ;
1919import { RefObject , useEffect , useState } from 'react' ;
2020
@@ -114,7 +114,7 @@ function endDragging() {
114114
115115export function isValidDropTarget ( element : Element ) : boolean {
116116 for ( let target of dropTargets . keys ( ) ) {
117- if ( target . contains ( element ) ) {
117+ if ( nodeContains ( target , element ) ) {
118118 return true ;
119119 }
120120 }
@@ -243,7 +243,7 @@ class DragSession {
243243 this . cancelEvent ( e ) ;
244244
245245 if ( e . key === 'Enter' ) {
246- if ( e . altKey || this . getCurrentActivateButton ( ) ?. contains ( e . target as Node ) ) {
246+ if ( e . altKey || nodeContains ( this . getCurrentActivateButton ( ) , e . target as Node ) ) {
247247 this . activate ( this . currentDropTarget , this . currentDropItem ) ;
248248 } else {
249249 this . drop ( ) ;
@@ -275,7 +275,7 @@ class DragSession {
275275
276276 let dropTarget =
277277 this . validDropTargets . find ( target => target . element === e . target as HTMLElement ) ||
278- this . validDropTargets . find ( target => target . element . contains ( e . target as HTMLElement ) ) ;
278+ this . validDropTargets . find ( target => nodeContains ( target . element , e . target as HTMLElement ) ) ;
279279
280280 if ( ! dropTarget ) {
281281 // if (e.target === activateButton) {
@@ -321,10 +321,10 @@ class DragSession {
321321 this . cancelEvent ( e ) ;
322322 if ( isVirtualClick ( e ) || this . isVirtualClick ) {
323323 let dropElements = dropItems . values ( ) ;
324- let item = [ ...dropElements ] . find ( item => item . element === e . target as HTMLElement || item . activateButtonRef ?. current ?. contains ( e . target as HTMLElement ) ) ;
325- let dropTarget = this . validDropTargets . find ( target => target . element . contains ( e . target as HTMLElement ) ) ;
324+ let item = [ ...dropElements ] . find ( item => item . element === e . target as HTMLElement || nodeContains ( item . activateButtonRef ?. current , e . target as HTMLElement ) ) ;
325+ let dropTarget = this . validDropTargets . find ( target => nodeContains ( target . element , e . target as HTMLElement ) ) ;
326326 let activateButton = item ?. activateButtonRef ?. current ?? dropTarget ?. activateButtonRef ?. current ;
327- if ( activateButton ?. contains ( e . target as HTMLElement ) && dropTarget ) {
327+ if ( nodeContains ( activateButton , e . target as HTMLElement ) && dropTarget ) {
328328 this . activate ( dropTarget , item ) ;
329329 return ;
330330 }
@@ -401,7 +401,7 @@ class DragSession {
401401 // Filter out drop targets that contain valid items. We don't want to stop hiding elements
402402 // other than the drop items that exist inside the collection.
403403 let visibleDropTargets = this . validDropTargets . filter ( target =>
404- ! validDropItems . some ( item => target . element . contains ( item . element ) )
404+ ! validDropItems . some ( item => nodeContains ( target . element , item . element ) )
405405 ) ;
406406
407407 this . restoreAriaHidden = ariaHideOutside ( [
0 commit comments