Skip to content

Commit 9df3f8c

Browse files
Merge branch 'master' into chore/update-web-components
2 parents 7a68a27 + 530917c commit 9df3f8c

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

packages/main/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"lodash.debounce": "^4.0.8",
3030
"react-content-loader": "^4.3.2",
3131
"react-jss": "10.0.0",
32-
"react-table": "7.0.0-beta.12",
32+
"react-table": "7.0.0-beta.20",
3333
"react-toastify": "^5.4.1",
3434
"react-window": "^1.8.5"
3535
},

packages/main/src/components/AnalyticalTable/__snapshots__/AnalyticalTable.test.tsx.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,6 @@ exports[`AnalyticalTable Tree Table 1`] = `
17951795
style="align-items: center;"
17961796
>
17971797
<span
1798-
class=""
17991798
style="cursor: pointer; padding-left: 0px;"
18001799
title="Toggle Expanded"
18011800
>

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { makeTemplateColumns } from './hooks/utils';
3838
import { TitleBar } from './TitleBar';
3939
import { VirtualTableBody } from './virtualization/VirtualTableBody';
4040
import { useDragAndDrop } from './hooks/useDragAndDrop';
41+
import { reducer } from './tableReducer/reducer';
4142

4243
export interface ColumnConfiguration {
4344
accessor?: string;
@@ -154,12 +155,13 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
154155

155156
const getSubRows = useCallback((row) => row[subRowsKey] || [], [subRowsKey]);
156157

157-
const { getTableProps, headerGroups, rows, prepareRow, setState, state: tableState, setColumnOrder } = useTable(
158+
const { getTableProps, headerGroups, rows, prepareRow, state: tableState, setColumnOrder, dispatch } = useTable(
158159
{
159160
columns,
160161
data,
161162
defaultColumn: DefaultColumn,
162163
getSubRows,
164+
reducer,
163165
...reactTableOptions
164166
},
165167
useFilters,
@@ -185,13 +187,8 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
185187
);
186188

187189
useEffect(() => {
188-
setState((old) => {
189-
return {
190-
...old,
191-
groupBy
192-
};
193-
});
194-
}, [groupBy, setState]);
190+
dispatch({ type: 'SET_GROUP_BY', payload: groupBy });
191+
}, [groupBy, dispatch]);
195192

196193
const tableContainerClasses = StyleClassHelper.of(classes.tableContainer);
197194

@@ -236,20 +233,15 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
236233
} else {
237234
groupedColumns = tableState.groupBy.filter((group) => group !== column.id);
238235
}
239-
setState((old) => {
240-
return {
241-
...old,
242-
groupBy: groupedColumns
243-
};
244-
});
236+
dispatch({ type: 'SET_GROUP_BY', payload: groupedColumns });
245237
onGroup(
246238
Event.of(null, e.getOriginalEvent(), {
247239
column,
248240
groupedColumns
249241
})
250242
);
251243
},
252-
[tableState.groupBy, onGroup]
244+
[tableState.groupBy, onGroup, dispatch]
253245
);
254246

255247
const [headerRef, tableWidth] = useWindowResize();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const reducer = (newState, action, prevState) => {
2+
const { payload } = action;
3+
switch (action.type) {
4+
case 'SET_GROUP_BY':
5+
return { ...prevState, groupBy: payload };
6+
default:
7+
return newState;
8+
}
9+
};

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14519,10 +14519,10 @@ react-syntax-highlighter@^8.0.1:
1451914519
prismjs "^1.8.4"
1452014520
refractor "^2.4.1"
1452114521

14522-
14523-
version "7.0.0-beta.12"
14524-
resolved "https://registry.yarnpkg.com/react-table/-/react-table-7.0.0-beta.12.tgz#ae54b398fbdb527b9fad82e52c4d829c00fdd5dc"
14525-
integrity sha512-h1c0KNTBRPAMgZumaNixr3X0w7kFTuqk6pHwia12LsMgnTHNEEeqp7+tQ5fTPwwMArp1/OHXeOdSKEes1C83iw==
14522+
14523+
version "7.0.0-beta.20"
14524+
resolved "https://registry.yarnpkg.com/react-table/-/react-table-7.0.0-beta.20.tgz#2125726549a15d5fd1d264145c92b9807a82aa1e"
14525+
integrity sha512-809Zj/OHX+Jbfnb+kxULZDvDstHrpzjFl2+mYOF9pU1CcJKkL2GdBmlWr9pcDmznxMU6veJUYnAxXYqvAWKVrQ==
1452614526

1452714527
react-test-renderer@^16.0.0-0:
1452814528
version "16.8.6"

0 commit comments

Comments
 (0)