From abeee76ddda55d1d7e1d59d408a6056e2ea1d977 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Tue, 7 Jul 2026 23:22:20 +0900 Subject: [PATCH] #268 --- .../components/DraggableDroppableTagRow.tsx | 66 ++++++++++++------- frontend/src/components/TagDetailSidebar.tsx | 20 +++++- 2 files changed, 61 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/DraggableDroppableTagRow.tsx b/frontend/src/components/DraggableDroppableTagRow.tsx index ea1eda4..49f9aed 100644 --- a/frontend/src/components/DraggableDroppableTagRow.tsx +++ b/frontend/src/components/DraggableDroppableTagRow.tsx @@ -13,6 +13,7 @@ import type { CSSProperties, FC, MutableRefObject } from 'react' import type { Tag } from '@/types' type Props = { + activeDndId?: string tag: Tag nestLevel: number pathKey: string @@ -21,7 +22,15 @@ type Props = { sp?: boolean } -const DraggableDroppableTagRow: FC = ({ tag, nestLevel, pathKey, parentTagId, suppressClickRef, sp }) => { +const DraggableDroppableTagRow: FC = ({ + activeDndId, + tag, + nestLevel, + pathKey, + parentTagId, + suppressClickRef, + sp, +}) => { const behaviourSettings = useClientBehaviourSettings () const animationMode = behaviourSettings.animation ?? 'normal' const layoutTransition = clientAnimationTransition ( @@ -53,19 +62,23 @@ const DraggableDroppableTagRow: FC = ({ tag, nestLevel, pathKey, parentTa const { attributes, listeners, setNodeRef: setDragRef, - transform, - isDragging: dragging } = useDraggable ({ id: dndId, - data: { kind: 'tag', - tagId: tag.id, - parentTagId, - nestLevel } }) + transform } = useDraggable ({ id: dndId, + data: { kind: 'tag', + dndId, + tagId: tag.id, + parentTagId, + nestLevel } }) const { setNodeRef: setDropRef, isOver: over } = useDroppable ({ id: dndId, data: { kind: 'tag', tagId: tag.id } }) + const activeDragging = activeDndId === dndId const style: CSSProperties = { transform: CSS.Translate.toString (transform), - visibility: dragging ? 'hidden' : 'visible' } + visibility: activeDragging ? 'hidden' : 'visible' } + const innerClassName = cn ( + 'inline-flex min-w-0 max-w-full items-baseline overflow-hidden', + sp && 'touch-pan-y') return (
= ({ tag, nestLevel, pathKey, parentTa sp && 'touch-pan-y', over && 'ring-2 ring-offset-2')} > - - - + {activeDragging + ? ( +
+ +
) + : ( + + + )}
) } diff --git a/frontend/src/components/TagDetailSidebar.tsx b/frontend/src/components/TagDetailSidebar.tsx index 965cebc..45464dd 100644 --- a/frontend/src/components/TagDetailSidebar.tsx +++ b/frontend/src/components/TagDetailSidebar.tsx @@ -43,6 +43,7 @@ const alwaysMeasureDroppables = { const renderTagTree = ( + activeDndId: string | undefined, tag: TagWithSections, nestLevel: number, path: string, @@ -54,6 +55,7 @@ const renderTagTree = ( const self = (
  • a.name < b.name ? -1 : 1) .flatMap (child => - renderTagTree (child, nestLevel + 1, key, suppressClickRef, tag.id, sp))) + renderTagTree ( + activeDndId, + child, + nestLevel + 1, + key, + suppressClickRef, + tag.id, + sp))) ?? [])] } @@ -211,6 +220,7 @@ type Props = { sp?: boolean } type ActiveTagDrag = { + dndId: string tagId: number nestLevel: number } @@ -251,6 +261,7 @@ const TagDetailSidebar: FC = ({ className, post, sp }) => { () => buildFlatTagByCategory (tags), [tags], ) + const activeDndId = activeTagDrag?.dndId const suppressClickRef = useRef (false) @@ -366,10 +377,11 @@ const TagDetailSidebar: FC = ({ className, post, sp }) => { { const tagId = e.active.data.current?.tagId const nestLevel = e.active.data.current?.nestLevel + const dndId = e.active.data.current?.dndId setActiveTagDrag ( - tagId == null || nestLevel == null + tagId == null || nestLevel == null || dndId == null ? null - : { tagId, nestLevel }) + : { dndId, tagId, nestLevel }) } setDragging (true) suppressClickRef.current = true @@ -426,6 +438,7 @@ const TagDetailSidebar: FC = ({ className, post, sp }) => { {(tagRelationDisplay === 'grouped' ? (tags[cat] ?? []).flatMap (tag => renderTagTree ( + activeDndId, tag, 0, `cat-${ cat }`, @@ -437,6 +450,7 @@ const TagDetailSidebar: FC = ({ className, post, sp }) => { : (flatTagsByCategory[cat] ?? []).map (tag => (