From 06cac027b3f57e95155d3bf01e08cafcf433f526 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Tue, 28 May 2019 15:54:47 -0500 Subject: [PATCH 1/4] allow for removing columns after sorting is applied --- src/components/basic_table/in_memory_table.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/basic_table/in_memory_table.js b/src/components/basic_table/in_memory_table.js index f83af9172bc..a5f4aab6212 100644 --- a/src/components/basic_table/in_memory_table.js +++ b/src/components/basic_table/in_memory_table.js @@ -282,7 +282,12 @@ export class EuiInMemoryTable extends Component { const { columns } = this.props; const sortColumn = columns.find(({ field }) => field === sortField); - const { sortable } = sortColumn; + + let sortable; + + if (sortColumn) { + sortable = sortColumn.sortable; + } if (typeof sortable === 'function') { return Comparators.value(sortable, Comparators.default(sortDirection)); From a913f1f372e1a35fa0cb913c136024ae2dccd705 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Tue, 28 May 2019 17:36:57 -0500 Subject: [PATCH 2/4] allow for updating sort config via props --- src/components/basic_table/in_memory_table.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/basic_table/in_memory_table.js b/src/components/basic_table/in_memory_table.js index a5f4aab6212..a02252e8532 100644 --- a/src/components/basic_table/in_memory_table.js +++ b/src/components/basic_table/in_memory_table.js @@ -167,9 +167,18 @@ export class EuiInMemoryTable extends Component { }, pageIndex: 0, }; - } else { - return null; } + const { sortField, sortDirection } = getInitialSorting(nextProps.sorting); + if ( + sortField !== prevState.prevProps.sortField || + sortDirection !== prevState.prevProps.sortDirection + ) { + return { + sortField, + sortDirection, + }; + } + return null; } constructor(props) { @@ -187,6 +196,8 @@ export class EuiInMemoryTable extends Component { this.state = { prevProps: { items: props.items, + sortField, + sortDirection, }, query: getInitialQuery(search), pageIndex, From 874ec2485bd68ee5af576442058a1a85dee5f078 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Wed, 29 May 2019 13:39:22 -0500 Subject: [PATCH 3/4] #1972 CL entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23dcbf87b84..826de54ece0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -- Update `caniuse-lite` version resolution ([#1970](https://github.com/elastic/eui/pull/1970)) +- Updated `caniuse-lite` version resolution ([#1970](https://github.com/elastic/eui/pull/1970)) +- Added ability to update `EuiInMemoryTable` `sorting` prop and remove columns after sorting is applied ([#1972](https://github.com/elastic/eui/pull/1972)) ## [`11.2.1`](https://github.com/elastic/eui/tree/v11.2.1) From bba306f2595249775355a178f5e1cc6a2d6c13ac Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Wed, 29 May 2019 14:01:39 -0500 Subject: [PATCH 4/4] past tense --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ee7fe5a703..f6424248fdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## [`master`](https://github.com/elastic/eui/tree/master) - Converted `EuiTableRowCellCheckbox` to TS ([#1964](https://github.com/elastic/eui/pull/1964)) -- Update `caniuse-lite` version resolution ([#1970](https://github.com/elastic/eui/pull/1970)) +- Updated `caniuse-lite` version resolution ([#1970](https://github.com/elastic/eui/pull/1970)) - Added a webpack directive for naming icon chunks ([#1944])(https://github.com/elastic/eui/pull/1944)) - Added ability to update `EuiInMemoryTable` `sorting` prop and remove columns after sorting is applied ([#1972](https://github.com/elastic/eui/pull/1972)) @@ -13,7 +13,7 @@ **Bug fixes** -- Fixes type mismatch between PropType and TypeScript def for `EuiToast` `title` ([#1962](https://github.com/elastic/eui/pull/1962)) +- Fixed type mismatch between PropType and TypeScript def for `EuiToast` `title` ([#1962](https://github.com/elastic/eui/pull/1962)) ## [`11.2.0`](https://github.com/elastic/eui/tree/v11.2.0)