From 1bfa61ae441458cdcd860eb39e617417d013f1fa Mon Sep 17 00:00:00 2001
From: srichman333 <sarah_n_richman@brown.edu>
Date: Mon, 7 Aug 2023 10:53:09 -0400
Subject: Issues when you remove a highlighted row more than 1 chart up the
 tree fixed

---
 src/client/views/nodes/DataVizBox/components/TableBox.tsx | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

(limited to 'src/client/views/nodes/DataVizBox/components/TableBox.tsx')

diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index 8a99d332f..a7cc3f2fb 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -52,7 +52,18 @@ export class TableBox extends React.Component<TableBoxProps> {
         return this._tableData.length ? Array.from(Object.keys(this._tableData[0])).filter(header => header!='') : [];
     }
 
+    filterSelectedRowsDown() {
+        if (!this.props.layoutDoc.selected) this.props.layoutDoc.selected = new List<string>();
+        const selected = Cast(this.props.layoutDoc.selected, listSpec("string"), null);
+        const incomingSelected = this.incomingLinks.length? StrListCast(this.incomingLinks[0].selected) : undefined;
+        if (incomingSelected){
+            selected.map(guid => {
+                if (!incomingSelected.includes(guid)) selected.splice(selected.indexOf(guid), 1)}); // filters through selected to remove guids that were removed in the incoming data
+        }
+    }
+
     render() {
+        this.filterSelectedRowsDown();
         if (this._tableData.length>0){
             return (
                 <div className="table-container" style={{height: this.props.height+this.props.margin.top+this.props.margin.bottom}}>
@@ -133,7 +144,6 @@ export class TableBox extends React.Component<TableBoxProps> {
                                 if (containsData){
                                     return (
                                         <tr key={i} className="table-row" onClick={action(e => {
-                                                if (!this.props.layoutDoc.selected) this.props.layoutDoc.selected = new List<string>();
                                                 const selected = Cast(this.props.layoutDoc.selected, listSpec("string"), null);
                                                 if (selected.includes(guid)) selected.splice(selected.indexOf(guid), 1);
                                                 else {
-- 
cgit v1.2.3-70-g09d2

