Skip to content

Commit 46b79f1

Browse files
committed
Update.
1 parent 99fccf1 commit 46b79f1

4 files changed

Lines changed: 357 additions & 347 deletions

File tree

src/components/Information.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Information = ({
2929

3030
return (
3131
<div {...additionalProps} className={classNames}>
32-
{totalRowsText} {totalCount}{" "}
32+
{totalRowsText} {totalCount || 0}&nbsp;
3333
{!isPaginated
3434
? ""
3535
: `| ${rowsText} ${

src/hooks/useRowSelection.jsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,30 @@ const useRowSelection = (props, tableManager) => {
3535

3636
const selectAllRef = useRef(null);
3737

38+
const {
39+
selectedRowsIds: selectedRows,
40+
setSelectedRowsIds: setSelectedRows,
41+
getIsRowSelectable,
42+
} = rowSelectionApi;
43+
3844
rowSelectionApi.selectAll = useMemo(() => {
3945
const mode = props.selectAllMode;
4046
const allRows = mode === "all" ? rows : pageRows;
4147
const selectableItemsIds = allRows
4248
.filter((row) => row)
43-
.filter(rowSelectionApi.getIsRowSelectable)
49+
.filter(getIsRowSelectable)
4450
.map((item) => item[rowIdField]);
4551
const checked =
4652
selectableItemsIds.length &&
4753
selectableItemsIds.every((selectableItemId) =>
48-
rowSelectionApi.selectedRowsIds.find(
49-
(id) => selectableItemId === id
50-
)
54+
selectedRows.find((id) => selectableItemId === id)
5155
);
5256
const disabled = !selectableItemsIds.length;
5357
const indeterminate = !!(
54-
rowSelectionApi.selectedRowsIds.length &&
58+
selectedRows.length &&
5559
!checked &&
5660
selectableItemsIds.some((selectableItemId) =>
57-
rowSelectionApi.selectedRowsIds.find(
58-
(id) => selectableItemId === id
59-
)
61+
selectedRows.find((id) => selectableItemId === id)
6062
)
6163
);
6264

@@ -67,7 +69,7 @@ const useRowSelection = (props, tableManager) => {
6769
disabled,
6870
indeterminate,
6971
onChange: () => {
70-
let newSelectedRowsIds = [...rowSelectionApi.selectedRowsIds];
72+
let newSelectedRowsIds = [...selectedRows];
7173

7274
if (checked || indeterminate)
7375
newSelectedRowsIds = newSelectedRowsIds.filter(
@@ -79,10 +81,18 @@ const useRowSelection = (props, tableManager) => {
7981
newSelectedRowsIds.push(s)
8082
);
8183

82-
rowSelectionApi.setSelectedRowsIds(newSelectedRowsIds);
84+
setSelectedRows(newSelectedRowsIds);
8385
},
8486
};
85-
}, [props.selectAllMode, rows, pageRows, rowSelectionApi, rowIdField]);
87+
}, [
88+
props.selectAllMode,
89+
rows,
90+
pageRows,
91+
getIsRowSelectable,
92+
selectedRows,
93+
rowIdField,
94+
setSelectedRows,
95+
]);
8696

8797
useEffect(() => {
8898
if (!selectAllRef.current) return;

0 commit comments

Comments
 (0)