From 87e51631a9031f6c0fe32a769ae71b3bc91197fc Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Tue, 27 Jan 2026 11:25:19 +0100 Subject: [PATCH 1/2] fix navigation race condition --- src/components/Modal/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx index 25a1ad6b10f4b..befd4ad21f69d 100644 --- a/src/components/Modal/index.tsx +++ b/src/components/Modal/index.tsx @@ -21,9 +21,16 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = ( }; const hideModal = () => { - onModalHide(); if ((window.history.state as WindowState)?.shouldGoBack && shouldHandleNavigationBack) { + // Wait for history.back() to complete before calling onModalHide to prevent navigation race conditions + const handleHistoryBack = () => { + onModalHide(); + window.removeEventListener('popstate', handleHistoryBack); + }; + window.addEventListener('popstate', handleHistoryBack, {once: true}); window.history.back(); + } else { + onModalHide(); } }; From fee4ba27ebd7a91ef8e15178cd5dd4a3ae1126ae Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Tue, 27 Jan 2026 12:45:22 +0100 Subject: [PATCH 2/2] remove unnecessary code --- src/components/Modal/index.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx index befd4ad21f69d..4177f7e2c26b0 100644 --- a/src/components/Modal/index.tsx +++ b/src/components/Modal/index.tsx @@ -23,11 +23,7 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = ( const hideModal = () => { if ((window.history.state as WindowState)?.shouldGoBack && shouldHandleNavigationBack) { // Wait for history.back() to complete before calling onModalHide to prevent navigation race conditions - const handleHistoryBack = () => { - onModalHide(); - window.removeEventListener('popstate', handleHistoryBack); - }; - window.addEventListener('popstate', handleHistoryBack, {once: true}); + window.addEventListener('popstate', onModalHide, {once: true}); window.history.back(); } else { onModalHide();