= ({ tag, nestLevel, pathKey, parentTa
return
const dx = e.clientX - p.x
const dy = e.clientY - p.y
+
if (dx * dx + dy * dy >= 9)
armEatNextClick ()
}}
onPointerUpCapture={() => {
downPosRef.current = null
}}
+ onPointerCancelCapture={() => {
+ downPosRef.current = null
+ }}
onClickCapture={e => {
if (suppressClickRef.current)
{
@@ -90,24 +108,35 @@ const DraggableDroppableTagRow: FC
= ({ tag, nestLevel, pathKey, parentTa
e.stopPropagation ()
}
}}
- ref={node => {
- setDragRef (node)
- setDropRef (node)
- }}
- style={style}
+ ref={setDropRef}
className={cn (
'min-w-0 max-w-full overflow-hidden rounded select-none',
+ sp && 'touch-pan-y',
over && 'ring-2 ring-offset-2')}
- {...attributes}
- {...listeners}>
-
-
-
+ >
+ {activeDragging
+ ? (
+
+
+
)
+ : (
+
+
+ )}
)
}
diff --git a/frontend/src/components/TagDetailSidebar.tsx b/frontend/src/components/TagDetailSidebar.tsx
index 79b31db..63fbfd2 100644
--- a/frontend/src/components/TagDetailSidebar.tsx
+++ b/frontend/src/components/TagDetailSidebar.tsx
@@ -1,11 +1,13 @@
import { DndContext,
DragOverlay,
+ MeasuringStrategy,
MouseSensor,
TouchSensor,
+ pointerWithin,
useDroppable,
useSensor,
useSensors } from '@dnd-kit/core'
-import { restrictToWindowEdges } from '@dnd-kit/modifiers'
+import { restrictToWindowEdges, snapCenterToCursor } from '@dnd-kit/modifiers'
import { useQueryClient } from '@tanstack/react-query'
import { motion } from 'framer-motion'
import { useEffect, useMemo, useRef, useState } from 'react'
@@ -25,15 +27,23 @@ import { postsKeys, tagsKeys } from '@/lib/queryKeys'
import { useClientBehaviourSettings } from '@/lib/useClientBehaviourSettings'
import { dateString, originalCreatedAtString } from '@/lib/utils'
-import type { DragEndEvent } from '@dnd-kit/core'
+import type { CollisionDetection, DragEndEvent } from '@dnd-kit/core'
import type { FC, MutableRefObject, ReactNode } from 'react'
import type { Category, Post, TagWithSections } from '@/types'
type TagByCategory = { [key in Category]: TagWithSections[] }
+const tagCollisionDetection: CollisionDetection = args => {
+ return pointerWithin (args)
+}
+
+const alwaysMeasureDroppables = {
+ droppable: { strategy: MeasuringStrategy.Always } } as const
+
const renderTagTree = (
+ activeDndId: string | undefined,
tag: TagWithSections,
nestLevel: number,
path: string,
@@ -45,6 +55,7 @@ const renderTagTree = (
const self = (