Skip to content

Commit 55b82ce

Browse files
fix(data-table): a cell's content never paints over pinned columns or the header (#3351)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2e5415e commit 55b82ce

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎openframe-frontend-core/src/__tests__/data-table-grid.test.tsx‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
type GridColumn,
1919
type GridLayoutOptions,
2020
} from '../components/ui/data-table/data-table-grid';
21+
import { DATA_TABLE_ROW_FRAME_CLASS } from '../components/ui/data-table/data-table-row-classes';
2122
import { useDataTable } from '../components/ui/data-table/use-data-table';
2223
import { LoadingScope } from '../components/ui/loading-scope';
2324

@@ -316,15 +317,24 @@ describe('DataTable grid layout', () => {
316317
it('draws every grid cell 48px high and the plain text cell on one line', () => {
317318
const { container } = render(<Grid />);
318319
const gridBody = gridBodyMarkup(container);
319-
const cellBoxes = [...gridBody.matchAll(/class="(flex h-12 items-center border-b border-ods-border[^"]*)"/g)].map(
320-
match => match[1],
321-
);
320+
const cellBoxes = [
321+
...gridBody.matchAll(/class="(isolate flex h-12 items-center border-b border-ods-border[^"]*)"/g),
322+
].map(match => match[1]);
322323
// 3 rows x (select, name, owner, more).
323324
expect(cellBoxes).toHaveLength(12);
324325
// A string cell (the owner column's grid form) is the default one-line text.
325326
expect(screen.getByText('grid:Ada').className).toContain('truncate');
326327
});
327328

329+
it('keeps what a cell draws inside the cell: every cell is its own stacking context', () => {
330+
// An input at `z-10` in a scrolling cell painted over the pinned column (`z-[1]`). Each cell isolates its content.
331+
const { container } = render(<Grid />);
332+
const cells = [...gridBodyMarkup(container).matchAll(/class="([^"]*\bh-12 items-center[^"]*)"/g)].map(m => m[1]);
333+
expect(cells.length).toBeGreaterThan(0);
334+
for (const cell of cells) expect(cell.split(' ')).toContain('isolate');
335+
expect(DATA_TABLE_ROW_FRAME_CLASS.split(' ')).toContain('isolate');
336+
});
337+
328338
it('keeps every row 48px high when a column has two-line cells', () => {
329339
const twoLine = COLUMNS.map(column =>
330340
column.id === 'owner' ? { ...column, meta: { ...column.meta, gridSecondLine: true } } : column,

‎openframe-frontend-core/src/components/ui/data-table/data-table-grid.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ export const GRID_SUB_ROW_CLASS =
284284
*/
285285
export function gridCellClass(column: GridColumn, section: 'header' | 'body'): string {
286286
return cn(
287-
'flex h-12 items-center border-b border-ods-border',
287+
// `isolate`: a cell is its own stacking context, so nothing drawn inside it (an input at `z-10`, a badge, a
288+
// control's icon) can climb over the table's own layers listed above: a cell that scrolls stays under the pinned
289+
// cells, the gradients, the sub-rows and the header. The People Hub roster's picker (`relative z-10`) painted over
290+
// the pinned Employee column. Menus and popovers are portalled, so this holds nothing a cell means to escape.
291+
'isolate flex h-12 items-center border-b border-ods-border',
288292
section === 'header'
289293
? 'bg-ods-bg transition-colors duration-200'
290294
: 'bg-ods-card transition-colors group-hover/gridrow:bg-ods-bg-hover',

‎openframe-frontend-core/src/components/ui/data-table/data-table-row-classes.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ export const ROW_SHELL_CLASSES = 'items-center gap-[var(--spacing-system-mf)] px
3535
*/
3636
/** A row slot's box (its corners and its 1px border), shared by a row's card and a pad row, so both are one height. */
3737
const ROW_BOX_CLASS = 'overflow-hidden rounded-md border';
38-
/** A row's card (its frame and surface): read by `DataTableRow` and by the loading rows below, so both are one box. */
39-
export const DATA_TABLE_ROW_FRAME_CLASS = `${ROW_BOX_CLASS} border-ods-border bg-ods-card`;
38+
/**
39+
* A row's card (its frame and surface): read by `DataTableRow` and by the loading rows below, so both are one box.
40+
* `isolate`: the card is its own stacking context, so a cell's content with a `z-index` (an input, a badge) stays
41+
* inside it and passes under the table's sticky header (`z-10`) instead of over it.
42+
*/
43+
export const DATA_TABLE_ROW_FRAME_CLASS = `isolate ${ROW_BOX_CLASS} border-ods-border bg-ods-card`;
4044
/** A pad row (`PlaceholderRows`): the card's box with a transparent border, so it is the row's height and invisible. */
4145
export const DATA_TABLE_PAD_ROW_FRAME_CLASS = `pointer-events-none relative ${ROW_BOX_CLASS} border-transparent`;
4246

0 commit comments

Comments
 (0)