Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiInMemoryTable] Error appears in console related to prop sorting.sort.direction #4138

Merged
merged 5 commits into from
Nov 4, 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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
27 changes: 27 additions & 0 deletions src/components/basic_table/in_memory_table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,33 @@ describe('EuiInMemoryTable', () => {
expect(component).toMatchSnapshot();
});

test('pagination with actions column and sorting set to true', async () => {
const props: EuiInMemoryTableProps<BasicItem> = {
...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(<EuiInMemoryTable {...props} />);

component
.find('EuiButtonEmpty[data-test-subj="pagination-button-1"]')
.simulate('click');
});

test('onTableChange callback', () => {
const props: EuiInMemoryTableProps<BasicItem> = {
...requiredProps,
Expand Down
5 changes: 4 additions & 1 deletion src/components/basic_table/in_memory_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,10 @@ export class EuiInMemoryTable<T> 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<T>).field === sortName) {
if (
'field' in column &&
(column as EuiTableFieldDataColumnType<T>).field === sortName
) {
sortName = column.name as keyof T;
break;
}
Expand Down