Skip to content

Commit bb4366c

Browse files
authored
Make TableView accept a UNSAFE_className (#3722)
1 parent 26fc8f5 commit bb4366c

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/@react-spectrum/table/src/TableView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ function TableView<T extends object>(props: SpectrumTableProps<T>, ref: DOMRef<H
360360
classNames(
361361
stylesOverrides,
362362
'react-spectrum-Table'
363-
)
363+
),
364+
styleProps.className
364365
)
365366
}
366367
layout={layout}

packages/@react-spectrum/table/test/Table.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,33 @@ describe('TableView', function () {
344344
expect(cells[5]).toHaveAttribute('aria-colindex', '4');
345345
});
346346

347+
it('accepts a UNSAFE_className', function () {
348+
let {getByRole} = render(
349+
<TableView aria-label="Table" data-testid="test" selectionMode="multiple" UNSAFE_className="test-class">
350+
<TableHeader>
351+
<Column>Foo</Column>
352+
<Column>Bar</Column>
353+
<Column>Baz</Column>
354+
</TableHeader>
355+
<TableBody>
356+
<Row>
357+
<Cell>Foo 1</Cell>
358+
<Cell>Bar 1</Cell>
359+
<Cell>Baz 1</Cell>
360+
</Row>
361+
<Row>
362+
<Cell>Foo 2</Cell>
363+
<Cell>Bar 2</Cell>
364+
<Cell>Baz 2</Cell>
365+
</Row>
366+
</TableBody>
367+
</TableView>
368+
);
369+
370+
let grid = getByRole('grid');
371+
expect(grid).toHaveAttribute('class', expect.stringContaining('test-class'));
372+
});
373+
347374
it('renders a dynamic table', function () {
348375
let {getByRole} = render(
349376
<TableView aria-label="Table">

0 commit comments

Comments
 (0)