Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(table): honor className and style on TableRow (#4391)

Eloi Torrents9e52262c078f
diff --git a/.changeset/table-row-styling-props.md b/.changeset/table-row-styling-props.md
new file mode 100644
index 0000000000..de5729782e
--- /dev/null
+++ b/.changeset/table-row-styling-props.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] TableRow: honor `className` and `style` on the `<tr>`. `TableRowProps` extends `BaseProps`, but both were spread before `mergeProps()` and then overwritten by the component's own StyleX classes, so a consumer's values silently had no effect. They are now merged through `mergeProps()` alongside the row's StyleX styles, the same way `TableCell` and `TableHeaderCell` already handle them, in both the in-`Table` and standalone rendering paths. The Astryx theme classes and striped/hover styling are unchanged.
+@Eloitor
diff --git a/packages/core/src/Table/Table.test.tsx b/packages/core/src/Table/Table.test.tsx
index 89a6abad90..b23d870412 100644
--- a/packages/core/src/Table/Table.test.tsx
+++ b/packages/core/src/Table/Table.test.tsx
@@ -496,6 +496,37 @@ describe('BaseTable', () => {
});
});
+ describe('TableRow styling props', () => {
+ it('applies className and style to the row inside a Table', () => {
+ render(
+ <Table>
+ <tbody>
+ <TableRow className="custom-row" style={{opacity: 0.9}}>
+ <TableCell>Cell</TableCell>
+ </TableRow>
+ </tbody>
+ </Table>,
+ );
+ const row = screen.getByRole('row');
+ expect(row.className).toContain('custom-row');
+ expect(row.className).toContain('astryx-table-row');
+ expect(row.style.opacity).toBe('0.9');
+ });
+
+ it('applies className to a standalone row (no table context)', () => {
+ render(
+ <table>
+ <tbody>
+ <TableRow className="custom-row">
+ <td>Cell</td>
+ </TableRow>
+ </tbody>
+ </table>,
+ );
+ expect(screen.getByRole('row').className).toContain('custom-row');
+ });
+ });
+
describe('plugin pipeline', () => {
it('applies transformTable plugin', () => {
const plugin: TablePlugin<User> = {
diff --git a/packages/core/src/Table/TableRow.tsx b/packages/core/src/Table/TableRow.tsx
index 6b086b9b88..c7e544c03f 100644
--- a/packages/core/src/Table/TableRow.tsx
+++ b/packages/core/src/Table/TableRow.tsx
@@ -120,6 +120,8 @@ export function TableRow({
xstyle,
ref,
isHeaderRow = false,
+ className: incomingClassName,
+ style: incomingStyle,
...props
}: TableRowProps) {
const ctx = use(TableContext);
@@ -132,6 +134,8 @@ export function TableRow({
{...mergeProps(
themeProps('table-row'),
stylex.props(tableRowMarker, xstyle),
+ incomingClassName,
+ incomingStyle,
)}>
{children}
</tr>
@@ -169,6 +173,8 @@ export function TableRow({
{...mergeProps(
themeProps('table-row'),
stylex.props(tableRowMarker, ...rowStyles),
+ incomingClassName,
+ incomingStyle,
)}>
{children}
</tr>