Skip to content

Commit 5654553

Browse files
committed
Fix table group columns.
1 parent f95fe9b commit 5654553

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/components/table/body/header/cell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const BodyHeaderCell = ({ header, table, testPrefix, coloredSortedColumn, index
6767
? false
6868
: header.colSpan
6969
}
70-
width={`${column.getSize()}px`}
70+
width={`${header.subHeaders.length ? header.subHeaders.reduce((s, h) => s + h.column.getSize(), 0) : column.getSize()}px`}
7171
position="relative"
7272
{...(column.getCanSort() &&
7373
coloredSortedColumn &&

src/components/table/body/header/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import Flex from "@/components/templates/flex"
33
import { useTableState } from "../../provider"
44
import Cell from "./cell"
55

6-
const rerenderSelector = state => ({
7-
sizing: state.columnSizing,
8-
expanded: state.expanded,
9-
columnVisibility: state.columnVisibility,
10-
selectedRows: state.selectedRows,
11-
grouping: state.grouping,
12-
})
6+
const rerenderSelector = state => {
7+
return {
8+
sizing: state.columnSizing,
9+
expanded: state.expanded,
10+
columnVisibility: state.columnVisibility,
11+
selectedRows: state.selectedRows,
12+
grouping: state.grouping,
13+
columnsCount: state.table && state.table.getAllColumns().length,
14+
}
15+
}
1316

1417
const HeaderGroup = ({ headerGroup, testPrefix, ...rest }) => (
1518
<Flex
@@ -39,6 +42,7 @@ const HeaderGroups = ({ groups, size, side, ...rest }) => {
3942
zIndex={side ? 11 : undefined}
4043
width={`${size}px`}
4144
flex="grow"
45+
column
4246
>
4347
{groups.map(headerGroup => (
4448
<HeaderGroup headerGroup={headerGroup} key={headerGroup.id} {...rest} />

0 commit comments

Comments
 (0)