From cf80a523fd06d9b4a59355b2445ea5b897f12593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claud=C3=A9ric=20Demers?= Date: Mon, 23 Sep 2024 11:52:46 -0400 Subject: [PATCH] Update undefined ref guards --- packages/react/src/core/droppable/useDroppable.ts | 8 ++++++++ packages/react/src/sortable/useSortable.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/react/src/core/droppable/useDroppable.ts b/packages/react/src/core/droppable/useDroppable.ts index f923bd62..97b620d2 100644 --- a/packages/react/src/core/droppable/useDroppable.ts +++ b/packages/react/src/core/droppable/useDroppable.ts @@ -44,6 +44,14 @@ export function useDroppable( }, ref: useCallback( (element: Element | null) => { + if ( + !element && + droppable.element?.isConnected && + !droppable.manager?.dragOperation.status.idle + ) { + return; + } + droppable.element = element ?? undefined; }, [droppable] diff --git a/packages/react/src/sortable/useSortable.ts b/packages/react/src/sortable/useSortable.ts index 9ac6143a..b6eb6972 100644 --- a/packages/react/src/sortable/useSortable.ts +++ b/packages/react/src/sortable/useSortable.ts @@ -115,6 +115,14 @@ export function useSortable(input: UseSortableInput) { ), ref: useCallback( (element: Element | null) => { + if ( + !element && + sortable.element?.isConnected && + !manager?.dragOperation.status.idle + ) { + return; + } + sortable.element = element ?? undefined; }, [sortable]