From 4fc8598e365492aaaf5950783ebbff3d9316e561 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Wed, 1 Feb 2023 11:50:52 -0500 Subject: [PATCH] Keep tile elements in a stable order --- src/video-grid/NewVideoGrid.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/video-grid/NewVideoGrid.tsx b/src/video-grid/NewVideoGrid.tsx index a916f681..4a9d3f73 100644 --- a/src/video-grid/NewVideoGrid.tsx +++ b/src/video-grid/NewVideoGrid.tsx @@ -470,13 +470,8 @@ export const NewVideoGrid: FC = ({ if (slotGridGeneration !== grid.generation) return prevTiles ?? []; const slotCells = grid.cells.filter((c) => c?.slot) as Cell[]; - return zipWith(slotCells, slotRects, (cell, rect) => ({ - item: cell.item, - x: rect.x, - y: rect.y, - width: rect.width, - height: rect.height, - })); + const tileRects = new Map(zipWith(slotCells, slotRects, (cell, rect) => [cell.item, rect])) + return items.map(item => ({ ...tileRects.get(item)!, item })) }, [slotRects, grid, slotGridGeneration] );