Skip to content

Commit 0ee74fb

Browse files
committed
fix(web): prevent pinned threads reshuffling after drop
1 parent beab688 commit 0ee74fb

1 file changed

Lines changed: 39 additions & 30 deletions

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3744,36 +3744,45 @@ export default function Sidebar() {
37443744
routeDraftId={routeDraftIdForRows}
37453745
onNavigateToDraft={navigateToDraft}
37463746
/>,
3747-
<DndContext
3748-
key="pinned-dnd"
3749-
sensors={pinnedDndSensors}
3750-
collisionDetection={closestCenter}
3751-
modifiers={[restrictToVerticalAxis, restrictToFirstScrollableAncestor]}
3752-
onDragEnd={handlePinnedDragEnd}
3753-
>
3754-
<SortableContext
3755-
items={orderedPinnedThreads
3756-
.map((thread) =>
3757-
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
3758-
)
3759-
.filter((threadKey) => reorderablePinnedKeys.has(threadKey))}
3760-
strategy={verticalListSortingStrategy}
3761-
>
3762-
{orderedPinnedThreads.map((thread) => {
3763-
const threadKey = scopedThreadKey(
3764-
scopeThreadRef(thread.environmentId, thread.id),
3765-
);
3766-
if (!reorderablePinnedKeys.has(threadKey)) {
3767-
return renderThreadRow(thread, "pinned");
3768-
}
3769-
return (
3770-
<SortablePinnedThreadRow key={threadKey} id={threadKey}>
3771-
{(bag) => renderThreadRow(thread, "pinned", bag)}
3772-
</SortablePinnedThreadRow>
3773-
);
3774-
})}
3775-
</SortableContext>
3776-
</DndContext>,
3747+
pinnedThreads.length > 0 ? (
3748+
<li key="pinned-dnd" className="list-none">
3749+
<DndContext
3750+
sensors={pinnedDndSensors}
3751+
collisionDetection={closestCenter}
3752+
modifiers={[restrictToVerticalAxis, restrictToFirstScrollableAncestor]}
3753+
onDragEnd={handlePinnedDragEnd}
3754+
>
3755+
<SortableContext
3756+
items={orderedPinnedThreads
3757+
.map((thread) =>
3758+
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
3759+
)
3760+
.filter((threadKey) => reorderablePinnedKeys.has(threadKey))}
3761+
strategy={verticalListSortingStrategy}
3762+
>
3763+
<ul
3764+
role="list"
3765+
aria-label="Pinned threads"
3766+
className="flex flex-col gap-px"
3767+
>
3768+
{orderedPinnedThreads.map((thread) => {
3769+
const threadKey = scopedThreadKey(
3770+
scopeThreadRef(thread.environmentId, thread.id),
3771+
);
3772+
if (!reorderablePinnedKeys.has(threadKey)) {
3773+
return renderThreadRow(thread, "pinned");
3774+
}
3775+
return (
3776+
<SortablePinnedThreadRow key={threadKey} id={threadKey}>
3777+
{(bag) => renderThreadRow(thread, "pinned", bag)}
3778+
</SortablePinnedThreadRow>
3779+
);
3780+
})}
3781+
</ul>
3782+
</SortableContext>
3783+
</DndContext>
3784+
</li>
3785+
) : null,
37773786
];
37783787
if (pinnedThreads.length > 0) {
37793788
items.push(

0 commit comments

Comments
 (0)