Skip to content

Commit 78975f4

Browse files
committed
use expanded rows selector directly
1 parent a6e0191 commit 78975f4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/x-data-grid-pro/src/hooks/features/detailPanel/useGridDetailPanel.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export const useGridDetailPanel = (
8989
| 'onDetailPanelExpandedRowIdsChange'
9090
>,
9191
): void => {
92-
const expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
9392
const contentCache = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
9493

9594
const handleCellClick = React.useCallback<GridEventListener<'cellClick'>>(
@@ -283,7 +282,8 @@ export const useGridDetailPanel = (
283282

284283
const addDetailHeight = React.useCallback<GridPipeProcessor<'rowHeight'>>(
285284
(initialValue, row) => {
286-
if (!expandedRowIds || expandedRowIds.size === 0 || !expandedRowIds.has(row.id)) {
285+
const expandedRowIds = gridDetailPanelExpandedRowIdsSelector(apiRef);
286+
if (!expandedRowIds || !expandedRowIds.has(row.id)) {
287287
initialValue.detail = 0;
288288
return initialValue;
289289
}
@@ -295,7 +295,7 @@ export const useGridDetailPanel = (
295295
initialValue.detail = heightCache[row.id].height ?? 0; // Fallback to zero because the cache might not be ready yet (for example page was changed)
296296
return initialValue;
297297
},
298-
[apiRef, expandedRowIds, updateCachesIfNeeded],
298+
[apiRef, updateCachesIfNeeded],
299299
);
300300

301301
const enabled = props.getDetailPanelContent !== undefined;

0 commit comments

Comments
 (0)