Merge: fix back button swallowed after a button/ESC overlay close
This commit is contained in:
commit
703ae41f2d
1 changed files with 9 additions and 1 deletions
|
|
@ -66,9 +66,17 @@ export function useBackToClose(onClose: () => void): void {
|
||||||
const idx = overlayStack.lastIndexOf(token);
|
const idx = overlayStack.lastIndexOf(token);
|
||||||
if (idx !== -1) {
|
if (idx !== -1) {
|
||||||
// Closed programmatically (not via Back): drop our own history entry, and tell the
|
// Closed programmatically (not via Back): drop our own history entry, and tell the
|
||||||
// remaining overlays' handlers to ignore the resulting popstate.
|
// remaining overlays' handlers to ignore the resulting popstate. A one-shot listener
|
||||||
|
// clears the flag on that very popstate even when NO overlay remains underneath to
|
||||||
|
// consume it — otherwise suppressPop leaks `true` and silently swallows the NEXT
|
||||||
|
// overlay's first Back (reopen-after-button-close → first Back does nothing).
|
||||||
overlayStack.splice(idx, 1);
|
overlayStack.splice(idx, 1);
|
||||||
suppressPop = true;
|
suppressPop = true;
|
||||||
|
const clearSuppress = () => {
|
||||||
|
suppressPop = false;
|
||||||
|
window.removeEventListener("popstate", clearSuppress);
|
||||||
|
};
|
||||||
|
window.addEventListener("popstate", clearSuppress);
|
||||||
window.history.back();
|
window.history.back();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue