Skip to content

Commit b91fa88

Browse files
SunkenInTimeclaude
andcommitted
fix(web): reserve no space for an empty pinned section at rest
The pinned header kept one label of height at rest when there were no pins, which showed as an empty band above the first thread. The gap now exists only during a drag: the sorting strategy also projects active reorders when there are no pins, so the empty pinned header keeps its label height without the list reserving anything at rest. Fable 5.1 via Claude Code. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 5dc842e commit b91fa88

3 files changed

Lines changed: 46 additions & 12 deletions

File tree

‎apps/web/src/components/Sidebar.drag.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,40 @@ describe("sidebar drag projection", () => {
328328
},
329329
);
330330

331+
it("projects an active reorder with no pins so the empty pinned header keeps its label height", () => {
332+
const items = [
333+
pinnedHeader,
334+
divider,
335+
thread("a1", "active"),
336+
thread("a2", "active"),
337+
thread("a3", "active"),
338+
settledHeader,
339+
thread("s", "settled"),
340+
];
341+
const result = preview({ items, settledOrder: [], settledExpanded: true }, "a3", "a1");
342+
expect(result.get(sidebarMarkerId("pinned-header"))).toEqual(stationary);
343+
expect(result.get(sidebarMarkerId("pinned-divider"))?.y).toBe(16);
344+
expect(result.get("a3")).toEqual(stationary);
345+
expect(result.get("a1")?.y).toBe(99);
346+
expect(result.get("a2")?.y).toBe(99);
347+
expect(result.get(sidebarMarkerId("settled-header"))?.y).toBe(16);
348+
});
349+
350+
it("leaves an active reorder to the default strategy while pins exist", () => {
351+
const items = [
352+
pinnedHeader,
353+
thread("p", "pinned"),
354+
divider,
355+
thread("a1", "active"),
356+
thread("a2", "active"),
357+
settledHeader,
358+
thread("s", "settled"),
359+
];
360+
const result = preview({ items, settledOrder: [], settledExpanded: true }, "a2", "a1");
361+
expect(result.get(sidebarMarkerId("pinned-divider"))?.y).toBe(0);
362+
expect(result.get(sidebarMarkerId("settled-header"))?.y).toBe(0);
363+
});
364+
331365
it("keeps the pinned header above the first arriving pin", () => {
332366
const items = [
333367
pinnedHeader,

‎apps/web/src/components/Sidebar.drag.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212
const stationary = { x: 0, y: 0, scaleX: 1, scaleY: 1 };
1313

1414
/** Height kept for the pinned header while the previewed pinned section is
15-
* empty, so the Pinned and Active labels have room to stack. The header
16-
* reserves the same height at rest when there are no pins. */
15+
* empty, so the Pinned and Active labels have room to stack. It exists only
16+
* during a drag; nothing is reserved at rest. */
1717
const EMPTY_PINNED_HEADER_HEIGHT = 16;
1818
const hidden = { ...stationary, scaleY: 0 };
1919
type ThreadItem = Extract<SidebarListItem, { kind: "thread" }>;
@@ -79,8 +79,15 @@ export function createSidebarSortingStrategy(input: {
7979
if (active?.kind !== "thread" || !over || !rects[0]) return [];
8080
const target = resolveSidebarDropTarget(items, active.key, sidebarListItemId(over));
8181
if (!target) return [];
82-
if (target.section === active.section && over.kind === "thread")
83-
return target.section === "settled" ? [] : null;
82+
if (target.section === active.section && over.kind === "thread") {
83+
if (target.section === "settled") return [];
84+
// Reordering the active list with no pins still projects, so the
85+
// empty pinned header keeps its label height for the drag.
86+
const otherPins = items.some(
87+
(item) => item.kind === "thread" && item.section === "pinned" && item.key !== active.key,
88+
);
89+
if (target.section === "pinned" || otherPins) return null;
90+
}
8491
const groups: Record<SidebarSection, ThreadItem[]> = {
8592
pinned: [],
8693
active: [],

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,18 +578,12 @@ function SidebarDragBoundary(props: {
578578
label: string;
579579
visible: boolean;
580580
isDropTarget: boolean;
581-
// The pinned header keeps one label of height while there are no pins so
582-
// the Pinned and Active labels can stack instead of sharing a line.
583-
reserveHeight?: boolean;
584581
}) {
585582
return (
586583
<SortableSidebarMarker
587584
marker={props.marker}
588585
data-testid={`sidebar-${props.marker}`}
589-
className={cn(
590-
"pointer-events-none relative z-30 mx-0.5",
591-
props.reserveHeight ? "h-4" : "h-0",
592-
)}
586+
className="pointer-events-none relative z-30 mx-0.5 h-0"
593587
>
594588
{props.visible ? (
595589
<div className="absolute inset-x-2 top-0 flex h-4 -translate-y-1/2 items-center gap-1.5">
@@ -4732,7 +4726,6 @@ export default function Sidebar() {
47324726
label="Pinned"
47334727
visible={from !== null}
47344728
isDropTarget={dragTargetSection === "pinned"}
4735-
reserveHeight={pinnedThreads.length === 0}
47364729
/>,
47374730
);
47384731
break;

0 commit comments

Comments
 (0)