Skip to content

Commit

Permalink
Remove columnIndex from cellProps callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed May 25, 2018
1 parent f4cbb87 commit 775a0c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src-docs/src/views/tables/basic/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ export const Table = () => {
};
};

const getCellProps = (item, column, columnIndex) => {
const getCellProps = (item, column) => {
const { id } = item;
const { field } = column;
return {
className: 'customCellClass',
'data-test-subj': `cell-${id}-${columnIndex}`,
'data-test-subj': `cell-${id}-${field}`,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`EuiBasicTable cellProps renders cells with custom props from a callback
<EuiTableRowCell
align="left"
className="customRowClass"
data-test-subj="cell-1-0-name"
data-test-subj="cell-1-name"
header="Name"
key="_data_column_name_0_0"
onClick={[Function]}
Expand All @@ -47,7 +47,7 @@ exports[`EuiBasicTable cellProps renders cells with custom props from a callback
<EuiTableRowCell
align="left"
className="customRowClass"
data-test-subj="cell-2-0-name"
data-test-subj="cell-2-name"
header="Name"
key="_data_column_name_1_0"
onClick={[Function]}
Expand All @@ -66,7 +66,7 @@ exports[`EuiBasicTable cellProps renders cells with custom props from a callback
<EuiTableRowCell
align="left"
className="customRowClass"
data-test-subj="cell-3-0-name"
data-test-subj="cell-3-name"
header="Name"
key="_data_column_name_2_0"
onClick={[Function]}
Expand Down
6 changes: 3 additions & 3 deletions src/components/basic_table/basic_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ function getRowProps(item, rowProps) {
return {};
}

function getCellProps(item, column, columnIndex, cellProps) {
function getCellProps(item, column, cellProps) {
if (cellProps) {
if (isFunction(cellProps)) {
return cellProps(item, column, columnIndex);
return cellProps(item, column);
}
return cellProps;
}
Expand Down Expand Up @@ -681,7 +681,7 @@ export class EuiBasicTable extends Component {
const content = contentRenderer(value, item);

const { cellProps: cellPropsCallback } = this.props;
const cellProps = getCellProps(item, column, columnIndex, cellPropsCallback);
const cellProps = getCellProps(item, column, cellPropsCallback);

return (
<EuiTableRowCell
Expand Down
4 changes: 2 additions & 2 deletions src/components/basic_table/basic_table.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ describe('EuiBasicTable', () => {
description: 'description'
}
],
cellProps: (item, column, columnIndex) => {
cellProps: (item, column) => {
const { id } = item;
const { field } = column;
return {
'data-test-subj': `cell-${id}-${columnIndex}-${field}`,
'data-test-subj': `cell-${id}-${field}`,
className: 'customRowClass',
onClick: () => {},
};
Expand Down

0 comments on commit 775a0c3

Please sign in to comment.