Skip to content

Commit 7ec4cbe

Browse files
authored
Merge pull request Expensify#80606 from software-mansion-labs/collectioneur/fix-delete-transaction-race-condition
Fix navigation race condition when closing Wide RHP after the deletion of last transaction
2 parents a67796c + fee4ba2 commit 7ec4cbe

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/components/Modal/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
2121
};
2222

2323
const hideModal = () => {
24-
onModalHide();
2524
if ((window.history.state as WindowState)?.shouldGoBack && shouldHandleNavigationBack) {
25+
// Wait for history.back() to complete before calling onModalHide to prevent navigation race conditions
26+
window.addEventListener('popstate', onModalHide, {once: true});
2627
window.history.back();
28+
} else {
29+
onModalHide();
2730
}
2831
};
2932

0 commit comments

Comments
 (0)