Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-table] Fix refCallBack not working for table rows #2901

Merged
merged 2 commits into from
Mar 16, 2020
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
2 changes: 2 additions & 0 deletions packages/terra-table/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ChangeLog

Unreleased
----------
### Fixed
* Fixed refCallBack not working for table rows.

4.4.0 - (March 10, 2020)
------------------
Expand Down
1 change: 1 addition & 0 deletions packages/terra-table/src/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ const createRow = (tableData, rowData, rowIndex, sectionId) => {
isDisabled={rowData.isDisabled}
isStriped={rowData.isStriped}
dividerStyle={tableData.dividerStyle}
refCallback={rowData.refCallback}
>
{createCheckCell(rowData, tableData.rowStyle, tableData.checkStyle)}
{rowData.cells.map((cell, colIndex) => {
Expand Down
25 changes: 25 additions & 0 deletions packages/terra-table/tests/jest/Table.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@ describe('Table', () => {
expect(shallowComponent).toMatchSnapshot();
});

it('should render a Table with row and refCallback', () => {
const refCallback = jest.fn();
const shallowComponent = shallow(
<Table
summary="Test summary description"
summaryId="test-id"
numberOfColumns={0}
fill
scrollRefCallback={jest.fn()}
bodyData={[{
rows: [{
key: 'row-key',
refCallback,
cells: [{
key: 'child-cell-key',
id: 'child-cell-id',
children: 'content',
}],
}],
}]}
/>,
);
expect(shallowComponent).toMatchSnapshot();
});

it('should render a Table with padding standard', () => {
const shallowComponent = shallow(
<Table
Expand Down
36 changes: 36 additions & 0 deletions packages/terra-table/tests/jest/__snapshots__/Table.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,42 @@ exports[`Table should render a Table with padding standard 1`] = `
</div>
`;

exports[`Table should render a Table with row and refCallback 1`] = `
<div
aria-describedby="test-id"
aria-rowcount={1}
className="table fill outer"
role="grid"
>
<VisuallyHiddenText
id="test-id"
text="Test summary description"
/>
<div
className="body"
role="rowgroup"
tabIndex={0}
>
<Row
aria-rowindex={1}
isDisabled={false}
isSelectable={false}
isSelected={false}
isStriped={false}
key="row-key"
refCallback={[MockFunction]}
>
<Cell
key="child-cell-key"
removeInner={false}
>
content
</Cell>
</Row>
</div>
</div>
`;

exports[`Table should render a Table with row style toggle 1`] = `
<div
aria-describedby="test-id"
Expand Down