The open source coding agent.
TypeScript
fix(ui): prevent double-close and fix dialog replacement
David Hill7caf59b43390
diff --git a/packages/ui/src/context/dialog.tsx b/packages/ui/src/context/dialog.tsxindex 4d03b218dff..299f6032af1 100644--- a/packages/ui/src/context/dialog.tsx+++ b/packages/ui/src/context/dialog.tsx@@ -28,15 +28,18 @@ const Context = createContext<ReturnType<typeof init>>()function init() {const [active, setActive] = createSignal<Active | undefined>()+ let closing = falseconst close = () => {const current = active()- if (!current) return+ if (!current || closing) return+ closing = truecurrent.onClose?.()current.setClosing(true)setTimeout(() => {current.dispose()setActive(undefined)+ closing = false}, 100)}@@ -55,7 +58,13 @@ function init() {})const show = (element: DialogElement, owner: Owner, onClose?: () => void) => {- close()+ // Immediately dispose any existing dialog when showing a new one+ const current = active()+ if (current) {+ current.dispose()+ setActive(undefined)+ }+ closing = falseconst id = Math.random().toString(36).slice(2)let dispose: (() => void) | undefined