diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e8f6411028..92ec1c78652 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `30.2.0`. +**Bug fixes** + +- Fixed a condition in `EuiInMemoryTable` to avoid mistaken assignment of `sortName` ([#4138](https://github.com/elastic/eui/pull/4138)) ## [`30.2.0`](https://github.com/elastic/eui/tree/v30.2.0) diff --git a/src/components/basic_table/in_memory_table.test.tsx b/src/components/basic_table/in_memory_table.test.tsx index 0c2512c5ae8..fe66b22edbb 100644 --- a/src/components/basic_table/in_memory_table.test.tsx +++ b/src/components/basic_table/in_memory_table.test.tsx @@ -978,6 +978,33 @@ describe('EuiInMemoryTable', () => { expect(component).toMatchSnapshot(); }); + test('pagination with actions column and sorting set to true', async () => { + const props: EuiInMemoryTableProps = { + ...requiredProps, + items: [ + { id: '1', name: 'name1' }, + { id: '2', name: 'name2' }, + { id: '3', name: 'name3' }, + { id: '4', name: 'name4' }, + ], + columns: [ + { + name: 'Actions', + actions: [], + }, + ], + sorting: true, + pagination: { + pageSizeOptions: [2, 4, 6], + }, + }; + const component = mount(); + + component + .find('EuiButtonEmpty[data-test-subj="pagination-button-1"]') + .simulate('click'); + }); + test('onTableChange callback', () => { const props: EuiInMemoryTableProps = { ...requiredProps, diff --git a/src/components/basic_table/in_memory_table.tsx b/src/components/basic_table/in_memory_table.tsx index 2c11b8f0495..6c7cc1bc2bc 100644 --- a/src/components/basic_table/in_memory_table.tsx +++ b/src/components/basic_table/in_memory_table.tsx @@ -416,7 +416,10 @@ export class EuiInMemoryTable extends Component< // map back to `name` if this is the case for (let i = 0; i < this.props.columns.length; i++) { const column = this.props.columns[i]; - if ((column as EuiTableFieldDataColumnType).field === sortName) { + if ( + 'field' in column && + (column as EuiTableFieldDataColumnType).field === sortName + ) { sortName = column.name as keyof T; break; }