summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Hill <[email protected]>2026-01-26 16:45:59 +0000
committerDavid Hill <[email protected]>2026-01-26 19:47:57 +0000
commit7caf59b433902c70cf3ae18d6196248ba1bee9bc (patch)
treec7b9d403b3bd4525217ca29d78b1deaa28c63470
parent92229b44f885b78d6c729d5d2e71ddbe096d2672 (diff)
downloadopencode-7caf59b433902c70cf3ae18d6196248ba1bee9bc.tar.gz
opencode-7caf59b433902c70cf3ae18d6196248ba1bee9bc.zip
fix(ui): prevent double-close and fix dialog replacement
-rw-r--r--packages/ui/src/context/dialog.tsx13
1 files changed, 11 insertions, 2 deletions
diff --git a/packages/ui/src/context/dialog.tsx b/packages/ui/src/context/dialog.tsx
index 4d03b218d..299f6032a 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 = false
const close = () => {
const current = active()
- if (!current) return
+ if (!current || closing) return
+ closing = true
current.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 = false
const id = Math.random().toString(36).slice(2)
let dispose: (() => void) | undefined