Skip to content

Commit 522b594

Browse files
committed
fix(web): close the gap above the first diff file
Two sources, both above the first file header: `DIFF_PANEL_UNSAFE_CSS` shrinks the file header to match the app's type scale, but the virtualizer kept reserving its default `diffHeaderHeight` of 44px per file. The extra 11px per file is phantom scroll space, and when everything is collapsed the content is shorter than the viewport, so the sticky window's positive top inset pushes it down by exactly that slack -- a gap that grows with the file count. Pin the header height in CSS and hand the same constant to `itemMetrics.diffHeaderHeight` so the reserved and rendered heights agree. `min-height` is set alongside `height` because the library's own `min-height: 36px` otherwise wins. `layout.paddingTop: 8` then left an 8px gap above the first header at rest that disappeared as soon as the header pinned while scrolling. Drop it to 0 so the top of the list looks the same at rest and scrolled.
1 parent ac23e7b commit 522b594

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ interface CollapsedDiffFilesState {
8181

8282
const EMPTY_COLLAPSED_DIFF_FILE_KEYS: ReadonlySet<string> = new Set();
8383

84+
/**
85+
* Height of the file header rendered by `DIFF_PANEL_UNSAFE_CSS` below, in pixels. The diffs
86+
* virtualizer reserves scroll space per file from `itemMetrics.diffHeaderHeight`, so the two have to
87+
* agree: over-reserving leaves phantom scroll space that shows up as a gap above the first file.
88+
*/
89+
const DIFF_FILE_HEADER_HEIGHT = 33;
90+
8491
const DIFF_PANEL_UNSAFE_CSS = `
8592
[data-diffs-header],
8693
[data-diff],
@@ -133,7 +140,9 @@ const DIFF_PANEL_UNSAFE_CSS = `
133140
font-family: var(--font-sans) !important;
134141
font-size: 12px !important;
135142
line-height: 1 !important;
136-
min-height: 32px !important;
143+
box-sizing: border-box !important;
144+
height: ${DIFF_FILE_HEADER_HEIGHT}px !important;
145+
min-height: ${DIFF_FILE_HEADER_HEIGHT}px !important;
137146
padding-block: 6px !important;
138147
}
139148
@@ -915,7 +924,8 @@ export default function DiffPanel({
915924
themeType: resolvedTheme as DiffThemeType,
916925
unsafeCSS: DIFF_PANEL_UNSAFE_CSS,
917926
stickyHeaders: true,
918-
layout: { paddingTop: 8, paddingBottom: 8, gap: 8 },
927+
itemMetrics: { diffHeaderHeight: DIFF_FILE_HEADER_HEIGHT },
928+
layout: { paddingTop: 0, paddingBottom: 8, gap: 8 },
919929
}}
920930
/>
921931
</div>

0 commit comments

Comments
 (0)