@devries-cameron20 / t3code Mirror · read-only / commits / e42036485f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 08:45 UTC

Improve project drag collision detection in sidebar

- Prefer pointer-based hit testing during project reordering - Fall back to corner-based collision to make drop targeting more reliable

Julius Marminge committed Mar 9, 2026 at 14:25 UTC e42036485fd7fe19c8536ba3fd59573ebf592349
1 file changed +12 -2
apps/web/src/components/Sidebar.tsx
+12 -2
@@ -14,9 +14,11 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
14 import {
15 DndContext,
16 type DragCancelEvent,
17 + type CollisionDetection,
18 PointerSensor,
19 type DragStartEvent,
19 - closestCenter,
20 + closestCorners,
21 + pointerWithin,
22 useSensor,
23 useSensors,
24 type DragEndEvent,
@@ -841,6 +843,14 @@ export default function Sidebar() {
843 activationConstraint: { distance: 6 },
844 }),
845 );
846 + const projectCollisionDetection = useCallback<CollisionDetection>((args) => {
847 + const pointerCollisions = pointerWithin(args);
848 + if (pointerCollisions.length > 0) {
849 + return pointerCollisions;
850 + }
851 +
852 + return closestCorners(args);
853 + }, []);
854
855 const handleProjectDragEnd = useCallback(
856 (event: DragEndEvent) => {
@@ -1241,7 +1251,7 @@ export default function Sidebar() {
1251
1252 <DndContext
1253 sensors={projectDnDSensors}
1244 - collisionDetection={closestCenter}
1254 + collisionDetection={projectCollisionDetection}
1255 modifiers={[restrictToVerticalAxis, restrictToParentElement]}
1256 onDragStart={handleProjectDragStart}
1257 onDragEnd={handleProjectDragEnd}