From d9d936b7e8976afd8674fc6fe1e5378b6cd0fe63 Mon Sep 17 00:00:00 2001 From: Gagancreates Date: Fri, 8 May 2026 03:05:38 +0530 Subject: [PATCH] fix: stop reordering cached paths to keep iframe state alive --- .../renderer/src/components/persistent-viewer-cache.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/x/apps/renderer/src/components/persistent-viewer-cache.tsx b/apps/x/apps/renderer/src/components/persistent-viewer-cache.tsx index a8dfbbc5..c0f265fe 100644 --- a/apps/x/apps/renderer/src/components/persistent-viewer-cache.tsx +++ b/apps/x/apps/renderer/src/components/persistent-viewer-cache.tsx @@ -37,10 +37,9 @@ export function PersistentViewerCache({ activePath }: PersistentViewerCacheProps useEffect(() => { if (!isCacheable(activePath)) return setMountedPaths((prev) => { - if (prev.includes(activePath)) { - // Move to most-recent position - return [...prev.filter((p) => p !== activePath), activePath] - } + // Never reorder existing entries — moving a keyed iframe in the DOM + // detaches it, which causes the browser to re-navigate (state lost). + if (prev.includes(activePath)) return prev const next = [...prev, activePath] return next.length > CACHE_LIMIT ? next.slice(-CACHE_LIMIT) : next })