fix: enforce DataGrid cover boundary

This commit is contained in:
2026-07-31 04:44:24 +02:00
parent 7b8072d049
commit 5211e07d0b
4 changed files with 151 additions and 32 deletions
+96 -12
View File
@@ -94,13 +94,25 @@ assertWidths(
const overriddenOverflowLayout = fitDataGridColumns(weightedColumns, 500, {}, { primary: 450 });
assertWidths(
overriddenOverflowLayout.widths,
{ fixed: 72, primary: 328, secondary: 100 },
"a cover layout treats a persisted user width as preferred under viewport pressure"
{ fixed: 72, primary: 450, secondary: 100 },
"a cover layout preserves an explicit user width under viewport pressure"
);
assertEqual(
overriddenOverflowLayout.overflowWidth,
122,
"intentional user width may remain horizontally scrollable"
);
const overriddenUnderflowLayout = fitDataGridColumns(
weightedColumns,
800,
{},
{ fixed: 80, primary: 200, secondary: 200 }
);
assertEqual(
overriddenUnderflowLayout.underflowWidth,
0,
"a persisted user preference does not create avoidable horizontal overflow"
"a persisted cover layout is expanded when it would otherwise underflow"
);
const clampedOverrideLayout = fitDataGridColumns(weightedColumns, 800, {}, { primary: 900 }, "free");
@@ -176,15 +188,22 @@ const resizeBase = { first: 200, middle: 300, last: 300, actions: 100 };
const resizedFirst = resizeDataGridColumn(resizeColumns, resizeBase, "first", 120, "cover");
assertWidths(
resizedFirst.widths,
{ first: 320, middle: 240, last: 240, actions: 100 },
"right-side peers compensate an earlier cover-column resize"
{ first: 320, middle: 300, last: 300, actions: 100 },
"growing an earlier cover column may create horizontal overflow"
);
const shrunkFirst = resizeDataGridColumn(resizeColumns, resizeBase, "first", -80, "cover");
assertWidths(
shrunkFirst.widths,
{ first: 120, middle: 340, last: 340, actions: 100 },
"shrinking an earlier cover column grows resizable columns to its right"
);
const resizedLast = resizeDataGridColumn(resizeColumns, resizeBase, "last", 120, "cover");
assertWidths(
resizedLast.widths,
{ first: 140, middle: 240, last: 420, actions: 100 },
"left-side peers compensate the last resizable cover column"
{ first: 200, middle: 300, last: 420, actions: 100 },
"the last resizable cover column may grow into horizontal overflow"
);
const committedLayout = fitDataGridColumns(
@@ -197,7 +216,72 @@ const committedLayout = fitDataGridColumns(
assertWidths(
committedLayout.widths,
resizedLast.widths,
"committing a cover resize preserves the drag layout without a mouse-up snap"
"committing a cover resize preserves intentional overflow without a mouse-up snap"
);
const stoppedLastShrink = resizeDataGridColumn(
resizeColumns,
resizeBase,
"last",
-120,
"cover"
);
assertWidths(
stoppedLastShrink.widths,
resizeBase,
"the last resizable column stops before its shrink would require a filler"
);
assertEqual(
stoppedLastShrink.appliedDelta,
0,
"the stopped last-column shrink reports no applied movement"
);
const overflowedResizeBase = { first: 200, middle: 300, last: 420, actions: 100 };
const consumedLastOverflow = resizeDataGridColumn(
resizeColumns,
overflowedResizeBase,
"last",
-180,
"cover",
120
);
assertWidths(
consumedLastOverflow.widths,
{ first: 200, middle: 300, last: 300, actions: 100 },
"the last resizable column consumes overflow and stops at exact coverage"
);
assertEqual(
consumedLastOverflow.appliedDelta,
-120,
"last-column shrink is clamped to the available overflow"
);
const stillPastLastStop = resizeDataGridColumn(
resizeColumns,
overflowedResizeBase,
"last",
-150,
"cover",
120
);
assertWidths(
stillPastLastStop.widths,
consumedLastOverflow.widths,
"reversing the pointer while it remains beyond the stop does not move the column"
);
const crossedLastStop = resizeDataGridColumn(
resizeColumns,
overflowedResizeBase,
"last",
-110,
"cover",
120
);
assertEqual(
crossedLastStop.widths.last,
310,
"the column resumes only after the pointer crosses the cover boundary"
);
const fixedPeerResize = resizeDataGridColumn([
@@ -207,8 +291,8 @@ const fixedPeerResize = resizeDataGridColumn([
], { editable: 200, fixed: 300, actions: 100 }, "editable", 80, "cover");
assertWidths(
fixedPeerResize.widths,
{ editable: 280, fixed: 220, actions: 100 },
"non-resizable tracks may compensate layout without exposing a resize handle"
{ editable: 280, fixed: 300, actions: 100 },
"growth does not resize a fixed peer merely to avoid overflow"
);
const coverBeyondPassiveMax = resizeDataGridColumn([
@@ -218,8 +302,8 @@ const coverBeyondPassiveMax = resizeDataGridColumn([
], { first: 200, second: 300, actions: 100 }, "first", -80, "cover");
assertWidths(
coverBeyondPassiveMax.widths,
{ first: 120, second: 380, actions: 100 },
"cover compensation may exceed a peer's preferred maximum to retain full coverage"
{ first: 200, second: 300, actions: 100 },
"cover shrinking stops when right-side peers have reached their maximum"
);
const constrainedAtPassiveMax = resizeDataGridColumn([