diff --git a/apps/web/components/dashboard/tags/AllTagsView.tsx b/apps/web/components/dashboard/tags/AllTagsView.tsx index 99cc75a6..483fd8d4 100644 --- a/apps/web/components/dashboard/tags/AllTagsView.tsx +++ b/apps/web/components/dashboard/tags/AllTagsView.tsx @@ -60,15 +60,16 @@ function DeleteAllUnusedTags({ numUnusedTags }: { numUnusedTags: number }) { interface DragState { dragId: string | null; dragOverId: string | null; - x: number; - y: number; + // The position of the elements being dragged such that on drag over, we can revert the position. + initialX: number; + initialY: number; } const initialState: DragState = { - dragId: "", - dragOverId: "", - x: 0, - y: 0, + dragId: null, + dragOverId: null, + initialX: 0, + initialY: 0, }; let currentState: DragState = initialState; @@ -82,15 +83,15 @@ export default function AllTagsView({ }: { initialData: ZGetTagResponse[]; }) { - const [draggingEnabled, setDraggingEnabled] = React.useState(false); - const [sortByName, setSortByName] = React.useState(false); + const [draggingEnabled, toggleDraggingEnabled] = React.useState(false); + const [sortByName, toggleSortByName] = React.useState(false); function handleSortByNameChange(): void { - setSortByName(!sortByName); + toggleSortByName(!sortByName); } function handleDraggableChange(): void { - setDraggingEnabled(!draggingEnabled); + toggleDraggingEnabled(!draggingEnabled); } function handleDragStart(e: DraggableEvent, data: DraggableData): void { @@ -100,8 +101,8 @@ export default function AllTagsView({ currentState = { ...initialState, dragId: id, - x: data.x, - y: data.y, + initialX: data.x, + initialY: data.y, }; } @@ -147,7 +148,7 @@ export default function AllTagsView({ const { mutate: mergeTag } = useMergeTag({ onSuccess: () => { toast({ - description: "Tag has been updated!", + description: "Tags have been merged!", }); }, onError: (e) => { @@ -202,17 +203,15 @@ export default function AllTagsView({ } position={ !currentState.dragId - ? { x: currentState.x ?? 0, y: currentState.y ?? 0 } + ? { + x: currentState.initialX ?? 0, + y: currentState.initialY ?? 0, + } : undefined } > -
+
-
{tagsToPill(humanTags)}
+ {tagsToPill(humanTags)} @@ -265,7 +264,7 @@ export default function AllTagsView({ -
{tagsToPill(aiTags)}
+ {tagsToPill(aiTags)} @@ -288,9 +287,7 @@ export default function AllTagsView({ )}
- -
{tagsToPill(emptyTags)}
-
+ {tagsToPill(emptyTags)} );