Skip to content
TypeScript

fix(web): dragging a sidebar thread no longer scrolls the list to the bottom (#27691)

Julius Marminge86d8838e91b8
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index 1ed3065a92c..2d904e1ec6f 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -17,6 +17,7 @@ import {
DndContext,
useSensor,
useSensors,
+ type AutoScrollOptions,
type DragEndEvent,
type DragOverEvent,
type DragStartEvent,
@@ -876,6 +877,9 @@ function checkThreadOperations(
const SIDEBAR_DRAG_DISTANCE = 6;
+// dnd-kit's 20% edge zone at full speed runs the list away while the pointer rests near the bottom.
+const SIDEBAR_AUTO_SCROLL: AutoScrollOptions = { threshold: { x: 0, y: 0.05 }, acceleration: 3 };
+
const SIDEBAR_DRAG_LABEL_HEIGHT = 24;
const threadSearchResultId = (index: number) => `sidebar-thread-search-result-${index}`;
@@ -3280,7 +3284,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
>
<DndContext
sensors={dndSensors}
- autoScroll={!isContextDrag}
+ autoScroll={isContextDrag ? false : SIDEBAR_AUTO_SCROLL}
collisionDetection={dndCollisionDetection}
modifiers={dndModifiers}
onDragStart={handleThreadDragStart}