diff --git a/src/Table/Table.js b/src/Table/Table.js index 5a48bdd3f68693..a8f6d788222d9e 100644 --- a/src/Table/Table.js +++ b/src/Table/Table.js @@ -142,6 +142,14 @@ class Table extends Component { allRowsSelected: this.props.allRowsSelected, }; + componentWillReceiveProps(nextProps) { + if (typeof nextProps.allRowsSelected !== 'undefined' && this.props.allRowsSelected !== nextProps.allRowsSelected) { + this.setState({ + allRowsSelected: nextProps.selectAllSelected, + }); + } + } + isScrollbarVisible() { const tableDivHeight = this.refs.tableDiv.clientHeight; const tableBodyHeight = this.refs.tableBody.clientHeight; diff --git a/src/Table/TableBody.js b/src/Table/TableBody.js index 5c2102bdad1634..3c02c0699ca937 100644 --- a/src/Table/TableBody.js +++ b/src/Table/TableBody.js @@ -125,7 +125,11 @@ class TableBody extends Component { }; componentWillReceiveProps(nextProps) { - if (this.props.allRowsSelected && !nextProps.allRowsSelected) { + if (!this.props.allRowsSelected && nextProps.allRowsSelected) { + this.setState({ + selectedRows: [], + }); + } else if (this.props.allRowsSelected && !nextProps.allRowsSelected) { this.setState({ selectedRows: this.state.selectedRows.length > 0 ? [this.state.selectedRows[this.state.selectedRows.length - 1]] : [], @@ -139,7 +143,7 @@ class TableBody extends Component { } handleClickAway = () => { - if (this.props.deselectOnClickaway && this.state.selectedRows.length) { + if (this.props.deselectOnClickaway && (this.state.selectedRows.length || this.props.allRowsSelected)) { this.setState({ selectedRows: [], });