Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Active and Over in hasSortableData type guard #792

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sortable-type-guard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dnd-kit/sortable': patch
---

The `hasSortableData` type-guard that is exported by @dnd-kit/sortable has been updated to also accept the `Active` and `Over` interfaces so it can be used in events such as `onDragStart`, `onDragOver`, and `onDragEnd`.
12 changes: 10 additions & 2 deletions packages/sortable/src/types/type-guard.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import type {Data, DroppableContainer, DraggableNode} from '@dnd-kit/core';
import type {
Active,
Data,
DroppableContainer,
DraggableNode,
Over,
} from '@dnd-kit/core';

import type {SortableData} from './data';

export function hasSortableData<T extends DraggableNode | DroppableContainer>(
export function hasSortableData<
T extends Active | Over | DraggableNode | DroppableContainer
>(
entry: T | null | undefined
): entry is T & {data: {current: Data<SortableData>}} {
if (!entry) {
Expand Down