Skip to content

Commit 6629a6d

Browse files
committed
fix regression
1 parent 93fafd2 commit 6629a6d

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# CHANGELOG
22

3+
## 1.0.3
4+
5+
_2024-12-12_
6+
7+
### Bugix
8+
9+
- fix `expandedRows` regression
10+
311
## 1.0.2
412

513
_2024-12-12_

index.d.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ export type ExpanderProps<T> = {
2929
style: CSSProperties;
3030
};
3131

32-
export type ClearCacheOptions = {
33-
/**
34-
* this is used to skip the timeout and reset the table heights immeediately.
35-
*/
36-
forceUpdate?: boolean;
37-
/**
38-
* an optional timeout of how long to wait before resetting the table heights in ms (default: 50)
39-
*/
40-
timeout?: number;
41-
};
42-
4332
export type CellProps<T> = {
4433
/**
4534
* the data for the row
@@ -309,9 +298,10 @@ export type TableProps<T> = {
309298
*/
310299
footerClassname?: string;
311300
/**
312-
* an object that contains the expanded rows.
301+
* an object that contains the expanded rows. can also be a function that takes the index and
302+
* returns a boolean.
313303
*/
314-
expandedRows?: { [x: string | number]: boolean };
304+
expandedRows?: { [x: string | number]: boolean } | ((index: number) => boolean);
315305
/**
316306
* called when a row is expanded
317307
* @param value information about the row that is expanded/shrunk
@@ -360,6 +350,6 @@ export type TableProps<T> = {
360350
};
361351

362352
/**
363-
* A virtualized table build on top of `@tanstack/react-virtual`.
353+
* A virtualized table built on top of `@tanstack/react-virtual`.
364354
*/
365355
export const Table: <T>(props: TableProps<T> & { ref?: React.RefObject<TableRef> }) => JSX.Element;

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-fluid-table",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "A React table inspired by @tanstack/react-virtual",
55
"author": "Mckervin Ceme <mckervinc@live.com>",
66
"license": "MIT",
@@ -21,7 +21,8 @@
2121
"fluid",
2222
"virtualized",
2323
"list",
24-
"scrolling"
24+
"scrolling",
25+
"frozen"
2526
],
2627
"engines": {
2728
"node": ">=8",

src/components/List.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const List = forwardRef(function <T>(
9595
setPixelWidths(widths);
9696
}
9797
}, [remainingCols, fixedWidth, minColumnWidth, pixelWidths, columns]);
98+
const isRowExpanded = typeof expandedRows === "function" ? expandedRows : undefined;
9899

99100
const onExpand = useCallback(
100101
(
@@ -125,7 +126,7 @@ const List = forwardRef(function <T>(
125126

126127
// initialize expansion
127128
useEffect(() => {
128-
if (expandedRows) {
129+
if (expandedRows && typeof expandedRows !== "function") {
129130
setExpandedCache(expandedRows);
130131
}
131132
}, [expandedRows]);
@@ -181,7 +182,7 @@ const List = forwardRef(function <T>(
181182
{items.map(item => {
182183
const row = data[item.index];
183184
const key = generateKeyFromRow(row, item.index);
184-
const isExpanded = !!expandedCache[key];
185+
const isExpanded = isRowExpanded?.(item.index) ?? !!expandedCache[key];
185186
const className =
186187
typeof rowClassname === "function" ? rowClassname(item.index) : rowClassname;
187188
const style = typeof rowStyle === "function" ? rowStyle(item.index) : rowStyle;

src/styles/main.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
}
55

66
.rft-outer-container {
7-
will-change: height;
87
position: relative;
98
width: 100%;
109
}
@@ -14,7 +13,6 @@
1413
top: 0;
1514
left: 0;
1615
width: 100%;
17-
will-change: transform;
1816
}
1917

2018
.rft-sticky-header {

0 commit comments

Comments
 (0)