fix: change-password not working

Massimo Melina committed Jun 1, 2024 at 11:25 UTC 35365f903f535d3b685ce66edb7da7f8541f7aac
1 file changed +5 -3
shared/dialogs.ts
+5 -3
@@ -175,9 +175,11 @@ export function newDialog(options: DialogOptions) {
175 options.ts = ts
176 focusBak.push(document.activeElement) // saving this inside options object doesn't work (didn't dig enough to say why)
177 options = objSameKeys(options, x => isValidElement(x) ? ref(x) : x) as typeof options // encapsulate elements as react will try to write, but valtio makes them readonly
178 - dialogs.push(options)
179 - if (options.closable !== false)
180 - history.pushState({ $dialog: $id, ts, idx: history.state.idx + 1 }, '')
178 + setTimeout(() => { // in case dialogs were just closed, account for window.history delay. This should be harmless as ux is unaffected, and programmatically you already didn't expect this to happen immediately but at state change
179 + dialogs.push(options)
180 + if (options.closable !== false)
181 + history.pushState({ $dialog: $id, ts, idx: history.state.idx + 1 }, '')
182 + }, 1)
183 return { close }
184
185 function close(v?:any) {