From 4c8ae236524d5790b5d8f37285434ca210241ba7 Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Thu, 25 Sep 2025 07:37:53 +0200 Subject: [PATCH] Fix scroll element fallback in DragDropGrid virtualization Updated the getScrollElement function to fall back to containerRef.current if no scrolling container is found. This improves compatibility and prevents potential errors when the expected scrolling container is not present. --- frontend/src/components/pageEditor/DragDropGrid.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/pageEditor/DragDropGrid.tsx b/frontend/src/components/pageEditor/DragDropGrid.tsx index a5212bf1f..497876cd7 100644 --- a/frontend/src/components/pageEditor/DragDropGrid.tsx +++ b/frontend/src/components/pageEditor/DragDropGrid.tsx @@ -77,7 +77,7 @@ const DragDropGrid = ({ // Virtualization with react-virtual library const rowVirtualizer = useVirtualizer({ count: Math.ceil(items.length / itemsPerRow), - getScrollElement: () => containerRef.current?.closest('[data-scrolling-container]')!, + getScrollElement: () => containerRef.current?.closest('[data-scrolling-container]') ?? containerRef.current, estimateSize: () => { const remToPx = parseFloat(getComputedStyle(document.documentElement).fontSize); return parseFloat(GRID_CONSTANTS.ITEM_HEIGHT) * remToPx;