@dooherceg/material-react-table 4.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +33 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2296,7 +2296,39 @@ const MRT_ExpandButton = ({
|
|
|
2296
2296
|
const canExpand = row.getCanExpand() && (maxDepth === undefined || row.depth < maxDepth - 1);
|
|
2297
2297
|
const handleToggleExpand = event => {
|
|
2298
2298
|
event.stopPropagation();
|
|
2299
|
-
row.toggleExpanded()
|
|
2299
|
+
// row.toggleExpanded() is never called here. Its internal read of
|
|
2300
|
+
// row.table.atoms.expanded.get() can go stale relative to the live
|
|
2301
|
+
// table.getState() after repeated toggles on the same row (observed: a row's
|
|
2302
|
+
// second collapse silently no-ops - state and UI both stay exactly as they
|
|
2303
|
+
// were, with no error). table.getState()/table.setExpanded() stayed reliable
|
|
2304
|
+
// through the same repeated-toggle sequence, so the resulting map is always
|
|
2305
|
+
// built from those directly instead.
|
|
2306
|
+
const currentExpanded = table.getState().expanded;
|
|
2307
|
+
const isCurrentlyExpanded = currentExpanded === true || !!currentExpanded[row.id];
|
|
2308
|
+
if (isCurrentlyExpanded) {
|
|
2309
|
+
if (currentExpanded === true) {
|
|
2310
|
+
const next = {};
|
|
2311
|
+
Object.values(table.getRowModel().rowsById).forEach(otherRow => {
|
|
2312
|
+
if (otherRow.id !== row.id && otherRow.getCanExpand()) {
|
|
2313
|
+
next[otherRow.id] = true;
|
|
2314
|
+
}
|
|
2315
|
+
});
|
|
2316
|
+
table.setExpanded(next);
|
|
2317
|
+
} else {
|
|
2318
|
+
const next_0 = {
|
|
2319
|
+
...currentExpanded
|
|
2320
|
+
};
|
|
2321
|
+
delete next_0[row.id];
|
|
2322
|
+
table.setExpanded(next_0);
|
|
2323
|
+
}
|
|
2324
|
+
} else {
|
|
2325
|
+
// isCurrentlyExpanded is false, so currentExpanded can't be `true` here.
|
|
2326
|
+
const next_1 = {
|
|
2327
|
+
...currentExpanded
|
|
2328
|
+
};
|
|
2329
|
+
next_1[row.id] = true;
|
|
2330
|
+
table.setExpanded(next_1);
|
|
2331
|
+
}
|
|
2300
2332
|
iconButtonProps?.onClick?.(event);
|
|
2301
2333
|
};
|
|
2302
2334
|
const detailPanel = !!renderDetailPanel?.({
|