Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 416a919

Browse files
committed
tui: fix dialog replacement to prevent nested dialogs from showing simultaneously
1 parent dbbcf0b commit 416a919

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/ui/src/context/dialog.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const Context = createContext<ReturnType<typeof init>>()
2222
function init() {
2323
const [store, setStore] = createSignal<
2424
{
25+
id: string
2526
element: DialogElement
2627
onClose?: () => void
2728
owner: Owner
@@ -45,11 +46,13 @@ function init() {
4546
for (const item of store()) {
4647
item.onClose?.()
4748
}
49+
const id = Math.random().toString(36)
4850
setStore([
4951
{
52+
id,
5053
element: () =>
5154
runWithOwner(owner, () => (
52-
<Show when={result.stack.at(-1)?.owner === owner}>
55+
<Show when={result.stack.at(-1)?.id === id}>
5356
<Kobalte
5457
modal
5558
defaultOpen
@@ -79,11 +82,15 @@ function init() {
7982
setStore([])
8083
},
8184
}
85+
8286
return result
8387
}
8488

8589
export function DialogProvider(props: ParentProps) {
8690
const ctx = init()
91+
createEffect(() => {
92+
console.log("store", ctx.stack.length)
93+
})
8794
return (
8895
<Context.Provider value={ctx}>
8996
{props.children}

0 commit comments

Comments
 (0)