Skip to content

Commit

Permalink
Allow for updating sorting prop and removing columns from `EuiInMem…
Browse files Browse the repository at this point in the history
…oryTable` after sorting is applied (#1972)

* allow for removing columns after sorting is applied

* allow for updating sort config via props

* #1972 CL entry

* past tense
  • Loading branch information
thompsongl committed May 29, 2019
1 parent bf5c012 commit c50b2f4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
## [`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))
- Add a webpack directive for naming icon chunks ([#1944])(https://github.com/elastic/eui/pull/1944))
- 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))

**Bug fixes**

- Fixes environment setup for running `test-unit` script on Windows ([#1971](https://github.com/elastic/eui/pull/1971))
- Fixed environment setup for running `test-unit` script on Windows ([#1971](https://github.com/elastic/eui/pull/1971))

## [`11.2.1`](https://github.com/elastic/eui/tree/v11.2.1)

**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)

Expand Down
22 changes: 19 additions & 3 deletions src/components/basic_table/in_memory_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -187,6 +196,8 @@ export class EuiInMemoryTable extends Component {
this.state = {
prevProps: {
items: props.items,
sortField,
sortDirection,
},
query: getInitialQuery(search),
pageIndex,
Expand Down Expand Up @@ -282,7 +293,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));
Expand Down

0 comments on commit c50b2f4

Please sign in to comment.