From 04c84db0ae652bf2aa986cdda0beff5007ae6ebf Mon Sep 17 00:00:00 2001 From: codytseng Date: Wed, 7 May 2025 22:35:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PageManager.tsx | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/PageManager.tsx b/src/PageManager.tsx index 589c491f..5f9df8f7 100644 --- a/src/PageManager.tsx +++ b/src/PageManager.tsx @@ -207,20 +207,24 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { } const pushSecondaryPage = (url: string, index?: number) => { - setSecondaryStack((prevStack) => { - if (isCurrentPage(prevStack, url)) { - const currentItem = prevStack[prevStack.length - 1] - if (currentItem?.ref?.current) { - currentItem.ref.current.scrollToTop() + // FIXME: Temporary solution to prevent the back action after closing + // the modal when navigating. + setTimeout(() => { + setSecondaryStack((prevStack) => { + if (isCurrentPage(prevStack, url)) { + const currentItem = prevStack[prevStack.length - 1] + if (currentItem?.ref?.current) { + currentItem.ref.current.scrollToTop() + } + return prevStack } - return prevStack - } - const { newStack, newItem } = pushNewPageToStack(prevStack, url, maxStackSize, index) - if (newItem) { - window.history.pushState({ index: newItem.index, url }, '', url) - } - return newStack + const { newStack, newItem } = pushNewPageToStack(prevStack, url, maxStackSize, index) + if (newItem) { + window.history.pushState({ index: newItem.index, url }, '', url) + } + return newStack + }) }) }