fix: it may happen that opening HFS immediately does history.back(), exiting

Massimo Melina committed Apr 11, 2026 at 16:08 UTC 1f2bcfac98b9c44a6c1993ac9545f5652c4ba035
1 file changed +5 -7
shared/dialogs.ts
+5 -7
@@ -94,12 +94,10 @@ async function back() {
94 }))
95 }
96
97 -;(async () => {
98 - while (history.state?.$dialog) { // it happens if the user reloads the browser leaving open dialogs
99 - history.back()
100 - await wait(1) // history.state is not changed without this, on chrome123
101 - }
102 -})()
97 +if (history.state?.$dialog) { // it may happen if the user reloads the browser leaving open dialogs
98 + const { $dialog, ...state } = history.state
99 + history.replaceState(state, '')
100 +}
101
102 export function Dialogs(props: HTMLAttributes<HTMLDivElement>) {
103 useEffect(() => domOn('popstate', () => {
@@ -250,4 +248,4 @@ function closeDialogAt(i: number, value?: any) {
248
249 export function anyDialogOpen() {
250 return dialogs.length > 0
253 -}
\ No newline at end of file
251 +}