From 2cb7c7be97b52db92f5d6546e9be7c0ccd635de8 Mon Sep 17 00:00:00 2001 From: vicky-primathon <67091118+vicky-primathon@users.noreply.github.com> Date: Fri, 11 Sep 2020 17:07:33 +0530 Subject: [PATCH] Reset selected rows when table data is modified (#536) --- app/client/src/widgets/TableWidget.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/client/src/widgets/TableWidget.tsx b/app/client/src/widgets/TableWidget.tsx index ff0c45a34c..ef4ca184b5 100644 --- a/app/client/src/widgets/TableWidget.tsx +++ b/app/client/src/widgets/TableWidget.tsx @@ -333,9 +333,11 @@ class TableWidget extends BaseWidget { ); } componentDidUpdate(prevProps: TableWidgetProps) { - if ( + const tableDataUpdated = JSON.stringify(this.props.tableData) !== - JSON.stringify(prevProps.tableData) || + JSON.stringify(prevProps.tableData); + if ( + tableDataUpdated || JSON.stringify(this.props.filters) !== JSON.stringify(prevProps.filters) || this.props.searchText !== prevProps.searchText || @@ -359,6 +361,11 @@ class TableWidget extends BaseWidget { ); } } + if (tableDataUpdated) { + super.updateWidgetMetaProperty("selectedRowIndices", []); + super.updateWidgetMetaProperty("selectedRows", []); + super.updateWidgetMetaProperty("selectedRowIndex", -1); + } if (this.props.multiRowSelection !== prevProps.multiRowSelection) { if (this.props.multiRowSelection) { const selectedRowIndices = this.props.selectedRowIndex