summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/context
diff options
context:
space:
mode:
authoradamelmore <[email protected]>2026-01-29 20:07:35 -0600
committerAdam <[email protected]>2026-01-29 20:26:35 -0600
commit60de810d9a85db01c18f2c790f6af3b15105b9ee (patch)
tree459c2ad6a0d666fe3c2f5406aed5f92935a143af /packages/ui/src/context
parent95309c214903e1902e0b2b85177a3687af0fe6fa (diff)
downloadopencode-60de810d9a85db01c18f2c790f6af3b15105b9ee.tar.gz
opencode-60de810d9a85db01c18f2c790f6af3b15105b9ee.zip
fix(app): dialog not closing
Diffstat (limited to 'packages/ui/src/context')
-rw-r--r--packages/ui/src/context/dialog.tsx34
1 files changed, 27 insertions, 7 deletions
diff --git a/packages/ui/src/context/dialog.tsx b/packages/ui/src/context/dialog.tsx
index 299f6032a..afba5f648 100644
--- a/packages/ui/src/context/dialog.tsx
+++ b/packages/ui/src/context/dialog.tsx
@@ -28,18 +28,33 @@ const Context = createContext<ReturnType<typeof init>>()
function init() {
const [active, setActive] = createSignal<Active | undefined>()
- let closing = false
+ const timer = { current: undefined as ReturnType<typeof setTimeout> | undefined }
+ const lock = { value: false }
+
+ onCleanup(() => {
+ if (timer.current === undefined) return
+ clearTimeout(timer.current)
+ timer.current = undefined
+ })
const close = () => {
const current = active()
- if (!current || closing) return
- closing = true
+ if (!current || lock.value) return
+ lock.value = true
current.onClose?.()
current.setClosing(true)
- setTimeout(() => {
+
+ const id = current.id
+ if (timer.current !== undefined) {
+ clearTimeout(timer.current)
+ timer.current = undefined
+ }
+
+ timer.current = setTimeout(() => {
+ timer.current = undefined
current.dispose()
- setActive(undefined)
- closing = false
+ if (active()?.id === id) setActive(undefined)
+ lock.value = false
}, 100)
}
@@ -64,7 +79,12 @@ function init() {
current.dispose()
setActive(undefined)
}
- closing = false
+
+ if (timer.current !== undefined) {
+ clearTimeout(timer.current)
+ timer.current = undefined
+ }
+ lock.value = false
const id = Math.random().toString(36).slice(2)
let dispose: (() => void) | undefined