Reset selected rows when table data is modified (#536)

This commit is contained in:
vicky-primathon 2020-09-11 17:07:33 +05:30 committed by GitHub
parent 4b37c97fa7
commit 2cb7c7be97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -333,9 +333,11 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
); );
} }
componentDidUpdate(prevProps: TableWidgetProps) { componentDidUpdate(prevProps: TableWidgetProps) {
if ( const tableDataUpdated =
JSON.stringify(this.props.tableData) !== JSON.stringify(this.props.tableData) !==
JSON.stringify(prevProps.tableData) || JSON.stringify(prevProps.tableData);
if (
tableDataUpdated ||
JSON.stringify(this.props.filters) !== JSON.stringify(this.props.filters) !==
JSON.stringify(prevProps.filters) || JSON.stringify(prevProps.filters) ||
this.props.searchText !== prevProps.searchText || this.props.searchText !== prevProps.searchText ||
@ -359,6 +361,11 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
); );
} }
} }
if (tableDataUpdated) {
super.updateWidgetMetaProperty("selectedRowIndices", []);
super.updateWidgetMetaProperty("selectedRows", []);
super.updateWidgetMetaProperty("selectedRowIndex", -1);
}
if (this.props.multiRowSelection !== prevProps.multiRowSelection) { if (this.props.multiRowSelection !== prevProps.multiRowSelection) {
if (this.props.multiRowSelection) { if (this.props.multiRowSelection) {
const selectedRowIndices = this.props.selectedRowIndex const selectedRowIndices = this.props.selectedRowIndex