Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/DataTable/DataTable.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
}

.data-table__table {
width: 100%;
/*
* A user-resized column is an explicit layout contract. `width: 100%`
* lets the automatic table layout algorithm shrink that contract back to
* the scroll container, leaving a 600px header rendered at a much smaller
* width. Size to the content/declared columns instead, while retaining a
* full-width table when those columns fit the container.
*/
width: max-content;
min-width: 100%;
border-collapse: collapse;
table-layout: auto;
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/DataTable/DataTable.styles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ function contrast(a: Rgba, b: Rgba): number {
}

describe("DataTable resize grip styles", () => {
it("keeps declared column widths when the table overflows its local scroll container", () => {
expect(COMPONENT_CSS).toMatch(
/\.data-table__table\s*{[\s\S]*width:\s*max-content;/,
);
expect(COMPONENT_CSS).toMatch(/\.data-table__table\s*{[\s\S]*min-width:\s*100%;/);
expect(COMPONENT_CSS).toMatch(/\.data-table\s*{[\s\S]*overflow-x:\s*auto;/);
});

it("reserves a token-sized 24px-or-larger target outside header content", () => {
expect(COMPONENT_CSS).toMatch(
/\.data-table__cell--resizable\s*{[\s\S]*padding-inline-end/,
Expand Down
Loading