Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const DragDropContainer: React.FunctionComponent<DragDropContainerProps>

const collisionDetectionStrategy: CollisionDetection = useCallback(
(args) => {
if (activeId && activeId in items) {
if (activeId != null && activeId in items) {
return closestCenter({
...args,
droppableContainers: args.droppableContainers.filter((container) => container.id in items)
Expand Down Expand Up @@ -144,7 +144,7 @@ export const DragDropContainer: React.FunctionComponent<DragDropContainerProps>
if (hasRecentlyMovedContainer.current) {
lastOverId.current = activeId;
}
return lastOverId.current ? [{ id: lastOverId.current }] : [];
return lastOverId.current != null ? [{ id: lastOverId.current }] : [];
},
[activeId, items]
);
Expand All @@ -168,7 +168,7 @@ export const DragDropContainer: React.FunctionComponent<DragDropContainerProps>
const { id: activeId } = active;
const { id: overId } = over;

if (!overId || activeId in items) {
if (overId == null || activeId in items) {
return;
}

Expand Down Expand Up @@ -240,7 +240,7 @@ export const DragDropContainer: React.FunctionComponent<DragDropContainerProps>
};

const getDragOverlay = () => {
if (!activeId) {
if (activeId == null) {
return;
}
const item = findItem(activeId, findContainer(activeId));
Expand Down Expand Up @@ -290,7 +290,7 @@ export const DragDropContainer: React.FunctionComponent<DragDropContainerProps>
);
};

const dragOverlay = <DragOverlay>{activeId && getDragOverlay()}</DragOverlay>;
const dragOverlay = <DragOverlay>{activeId != null && getDragOverlay()}</DragOverlay>;

const portalTarget = typeof appendTo === 'function' ? appendTo() : appendTo || document.body;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ export interface DraggableProps extends React.HTMLProps<HTMLDivElement> {
id?: string;
/** Flag indicating the draggable element should include a drag button. */
useDragButton?: boolean;
/** Accessible name of the drag button. */
dragButtonAriaLabel?: string;
}

export const Draggable: React.FunctionComponent<DraggableProps> = ({
children,
id,
className,
useDragButton = false,
dragButtonAriaLabel,
...props
}: DraggableProps) => {
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
Expand All @@ -38,7 +41,7 @@ export const Draggable: React.FunctionComponent<DraggableProps> = ({
style={style}
{...props}
>
<DragButton {...attributes} {...listeners} />
<DragButton {...attributes} {...listeners} {...(dragButtonAriaLabel && { 'aria-label': dragButtonAriaLabel })} />
{children}
</div>
) : (
Expand Down
Loading