fix(grid): contain query grid scrollbars below sticky header

This commit is contained in:
Thanadon Kongkanun authored and GitHub committed 2026-09-25 23:56:08 +08:00
1 parent 070e09c615
commit 6db2589e37
2 files changed
+41

No files matched your search

@@ -13226,6 +13226,11 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val
</div> </div>
</div> </div>
<!-- Body wrapper: gives the vertical/horizontal scrollbars (absolutely
positioned) their own stacking context below the header, so their
`top`/`inset` offsets are measured from the body instead of from the
grid's outer relative container (which starts at the header row). -->
<div class="relative min-h-0 flex-1 flex flex-col overflow-hidden">
<div v-if="!hasVisibleRows" class="relative min-h-0 flex-1"> <div v-if="!hasVisibleRows" class="relative min-h-0 flex-1">
<div class="data-grid-scroller h-full overflow-x-auto overflow-y-hidden overscroll-none" :class="{ 'is-scrolling': isScrolling }" @scroll="onScrollerScroll" @wheel="onDomGridWheel"> <div class="data-grid-scroller h-full overflow-x-auto overflow-y-hidden overscroll-none" :class="{ 'is-scrolling': isScrolling }" @scroll="onScrollerScroll" @wheel="onDomGridWheel">
<div class="h-full min-h-[220px]" :style="{ width: 'max(100%, var(--total-w))' }" /> <div class="h-full min-h-[220px]" :style="{ width: 'max(100%, var(--total-w))' }" />
@@ -13657,6 +13662,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val
<div v-if="gridSurfaceBusy" class="absolute inset-0 z-20 flex items-center justify-center" :class="pageJumpProgress ? 'bg-background/35 backdrop-blur-[1px]' : 'bg-background/50'"> <div v-if="gridSurfaceBusy" class="absolute inset-0 z-20 flex items-center justify-center" :class="pageJumpProgress ? 'bg-background/35 backdrop-blur-[1px]' : 'bg-background/50'">
<DataGridBusyOverlay :elapsed-ms="loadingElapsed" :page-jump-progress="pageJumpProgress" :show-cancel="showCancel" :cancelling="cancelling" :cancel-disabled="cancelDisabled" @cancel="emit('cancel')" /> <DataGridBusyOverlay :elapsed-ms="loadingElapsed" :page-jump-progress="pageJumpProgress" :show-cancel="showCancel" :cancelling="cancelling" :cancel-disabled="cancelDisabled" @cancel="emit('cancel')" />
</div> </div>
</div>
</template> </template>
</div> </div>
<!-- Table Info Drawer --> <!-- Table Info Drawer -->
@@ -0,0 +1,35 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
// Fixes #10095: the vertical/horizontal scrollbar overlays are absolutely
// positioned relative to the nearest ancestor with `position: relative`.
// Before this fix that ancestor was the grid's *outer* wrapper, which starts
// at the sticky column-header row — so `top: 10px` on the vertical scrollbar
// (and the horizontal scrollbar's `bottom: 0`) were measured from the header,
// landing the scrollbar visually on top of the header instead of below it.
const dataGridSource = readFileSync(new URL("../DataGrid.vue", import.meta.url), "utf8");
describe("DataGrid scrollbar positioning", () => {
it("wraps the header-less scroll body in its own relative stacking context", () => {
const headerEnd = dataGridSource.indexOf('<div v-if="gridScrollbarGutter > 0" class="shrink-0 border-l border-border w-(--grid-scrollbar-gutter)" />\n </div>\n </div>');
expect(headerEnd).toBeGreaterThanOrEqual(0);
const wrapperStart = dataGridSource.indexOf('<div class="relative min-h-0 flex-1 flex flex-col overflow-hidden">', headerEnd);
expect(wrapperStart).toBeGreaterThan(headerEnd);
// The vertical scrollbar (and its horizontal sibling) must be inside the
// new wrapper, not siblings of the header at the outer level. Anchor on
// the "Table Info Drawer" comment that follows the wrapper's own closing
// tags — an inner RecycleScroller slot's `</template>` closes earlier and
// is not a safe upper bound.
const verticalScrollbarIndex = dataGridSource.indexOf('ref="gridVerticalScrollbarTrackRef"', wrapperStart);
const drawerCommentIndex = dataGridSource.indexOf("<!-- Table Info Drawer -->", wrapperStart);
expect(verticalScrollbarIndex).toBeGreaterThan(wrapperStart);
expect(verticalScrollbarIndex).toBeLessThan(drawerCommentIndex);
});
it("closes the wrapper before the sticky-header template ends, leaving markup balanced", () => {
const wrapperOpenCount = (dataGridSource.match(/<div class="relative min-h-0 flex-1 flex flex-col overflow-hidden">/g) || []).length;
expect(wrapperOpenCount).toBe(1);
});
});