Skip to content

Commit af1aadc

Browse files
authored
fix(AnalyticalTable): Resize table content correctly if columns are hidden or minWidth is set (#228)
1 parent fe98dcb commit af1aadc

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/main/src/components/AnalyticalTable/hooks/useWindowResize.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export const useWindowResize = () => {
1212

1313
const observer = useRef(new MutationObserver(onWindowResize));
1414

15+
useEffect(() => {
16+
if (headerRef.current && headerRef.current.getBoundingClientRect().width !== 0) {
17+
setTableWidth(headerRef.current.getBoundingClientRect().width);
18+
}
19+
}, [headerRef.current, setTableWidth]);
20+
1521
useEffect(() => {
1622
Device.resize.attachHandler(onWindowResize, null);
1723
return () => {

packages/main/src/components/AnalyticalTable/virtualization/VirtualTableBody.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export const VirtualTableBody = (props) => {
4747
if (resizedColumns.hasOwnProperty(item.accessor)) {
4848
return resizedColumns[item.accessor];
4949
}
50+
if (item.hasOwnProperty('show') && !item.show) {
51+
return 0;
52+
}
5053
return item.minWidth ? item.minWidth : DEFAULT_COLUMN_WIDTH;
5154
})
5255
.reduce((acc, val) => acc + val, 0);

0 commit comments

Comments
 (0)