mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-11 00:02:38 +02:00
fix: stop reordering cached paths to keep iframe state alive
This commit is contained in:
parent
49a50279da
commit
d9d936b7e8
1 changed files with 3 additions and 4 deletions
|
|
@ -37,10 +37,9 @@ export function PersistentViewerCache({ activePath }: PersistentViewerCacheProps
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isCacheable(activePath)) return
|
if (!isCacheable(activePath)) return
|
||||||
setMountedPaths((prev) => {
|
setMountedPaths((prev) => {
|
||||||
if (prev.includes(activePath)) {
|
// Never reorder existing entries — moving a keyed iframe in the DOM
|
||||||
// Move to most-recent position
|
// detaches it, which causes the browser to re-navigate (state lost).
|
||||||
return [...prev.filter((p) => p !== activePath), activePath]
|
if (prev.includes(activePath)) return prev
|
||||||
}
|
|
||||||
const next = [...prev, activePath]
|
const next = [...prev, activePath]
|
||||||
return next.length > CACHE_LIMIT ? next.slice(-CACHE_LIMIT) : next
|
return next.length > CACHE_LIMIT ? next.slice(-CACHE_LIMIT) : next
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue