Skip to content

Commit

Permalink
fix(AnalyticalTable): Resize table content correctly if columns are h…
Browse files Browse the repository at this point in the history
…idden or minWidth is set (#228)
  • Loading branch information
Lukas742 authored Nov 18, 2019
1 parent fe98dcb commit af1aadc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export const useWindowResize = () => {

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

useEffect(() => {
if (headerRef.current && headerRef.current.getBoundingClientRect().width !== 0) {
setTableWidth(headerRef.current.getBoundingClientRect().width);
}
}, [headerRef.current, setTableWidth]);

useEffect(() => {
Device.resize.attachHandler(onWindowResize, null);
return () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const VirtualTableBody = (props) => {
if (resizedColumns.hasOwnProperty(item.accessor)) {
return resizedColumns[item.accessor];
}
if (item.hasOwnProperty('show') && !item.show) {
return 0;
}
return item.minWidth ? item.minWidth : DEFAULT_COLUMN_WIDTH;
})
.reduce((acc, val) => acc + val, 0);
Expand Down

0 comments on commit af1aadc

Please sign in to comment.