Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/DataTable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1689,4 +1689,4 @@ After selecting the maximum possible number of rows, you can display an error me
</DataTable>
);
}
```
```
16 changes: 14 additions & 2 deletions src/DataTable/TableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ interface TableCellProps {
column: {
/** Class(es) to be applied to the cells in the given column */
cellClassName?: string;
/** Uniq ID of the column */
id?: string;
};
}
function TableCell({ getCellProps, render, column }: TableCellProps) {
const { className, ...rest } = getCellProps();

const isActionColumn = column.id === 'action';
const cellClasses = classNames(className, column.cellClassName);

return (
<td {...rest} className={classNames('pgn__data-table-cell-wrap', className, column.cellClassName)}>
{render('Cell')}
<td {...rest} className={cellClasses}>
{!isActionColumn ? (
<div className="pgn__data-table-cell-wrap">
{render('Cell')}
</div>
) : (
render('Cell')
)}
</td>
);
}
Expand Down
3 changes: 1 addition & 2 deletions src/DataTable/tests/TableRow.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ describe('<TableRow />', () => {
});

it('does not render subcomponent if row is in expanded state and does not have renderRowSubComponent function defined', () => {
const { container } = render(<TableRowWrapper value={{}} row={{ ...props, isExpanded: true }} />);
render(<TableRowWrapper value={{}} row={{ ...props, isExpanded: true }} />);
const rows = screen.getAllByRole('row');
expect(rows.length).toEqual(1);
expect(container.querySelector('div')).not.toBeInTheDocument();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before changes in TableCell, the test checks container.querySelector('div') and expects no div, but now TableCell always creates a div with class pgn__data-table-cell-wrap for regular columns.

Let's update this test so that it checks for the absence of a second row (subcomponent) rather than the absence of any div.

});
});