fix(grid): keep DOM results at the first row

This commit is contained in:
t8y2 committed 2026-08-27 11:08:42 +08:00
1 parent 8bc31d3319
commit d2326acb81
3 files changed
+36 -1

No files matched your search

@@ -29,6 +29,10 @@ describe("data grid bottom anchoring", () => {
it("does not anchor a user who is away from the bottom", () => {
expect(isDataGridAtScrollBottom({ scrollTop: 700, scrollHeight: 1000, clientHeight: 260 })).toBe(false);
});
it("does not treat an unmeasured non-scrollable grid as bottom-anchored", () => {
expect(isDataGridAtScrollBottom({ scrollTop: 0, scrollHeight: 500, clientHeight: 500 })).toBe(false);
});
});
describe("data grid horizontal restoration", () => {
@@ -69,7 +69,7 @@ export function didDataGridInfiniteScrollContextChange(current: readonly string[
export function isDataGridAtScrollBottom(metrics: DataGridScrollMetrics, tolerance = 1): boolean {
const maxScrollTop = Math.max(0, metrics.scrollHeight - metrics.clientHeight);
return maxScrollTop - metrics.scrollTop <= tolerance;
return maxScrollTop > tolerance && maxScrollTop - metrics.scrollTop <= tolerance;
}
export function dataGridBottomScrollTop(metrics: Pick<DataGridScrollMetrics, "scrollHeight" | "clientHeight">): number {