Skip to content

Commit

Permalink
Update undefined ref guards
Browse files Browse the repository at this point in the history
  • Loading branch information
clauderic committed Sep 23, 2024
1 parent d26fafe commit cf80a52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/react/src/core/droppable/useDroppable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ export function useDroppable<T extends Data = Data>(
},
ref: useCallback(
(element: Element | null) => {
if (
!element &&
droppable.element?.isConnected &&
!droppable.manager?.dragOperation.status.idle
) {
return;
}

droppable.element = element ?? undefined;
},
[droppable]
Expand Down
8 changes: 8 additions & 0 deletions packages/react/src/sortable/useSortable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ export function useSortable<T extends Data = Data>(input: UseSortableInput<T>) {
),
ref: useCallback(
(element: Element | null) => {
if (
!element &&
sortable.element?.isConnected &&
!manager?.dragOperation.status.idle
) {
return;
}

sortable.element = element ?? undefined;
},
[sortable]
Expand Down

0 comments on commit cf80a52

Please sign in to comment.