Skip to content

Commit 3fd9bc7

Browse files
committed
refactor(dialog): use new useStack register/select pattern
- Remove disableGlobalStack prop (no longer needed) - Use stack.register() with onDismiss callback - Watch isOpen to select/unselect ticket - Compute styles from ticket.zIndex
1 parent 8dda5e9 commit 3fd9bc7

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

packages/0/src/components/Dialog/DialogContent.vue

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626
* @remarks When true, clicking the scrim will not dismiss this dialog. Use for critical dialogs requiring explicit user action.
2727
*/
2828
blocking?: boolean
29-
/**
30-
* Disable global stack participation
31-
*
32-
* @default false
33-
* @remarks When true, the dialog tracks parent/child relationships but doesn't register in the global stack.
34-
*/
35-
disableGlobalStack?: boolean
3629
}
3730
3831
export interface DialogContentEmits {
@@ -83,7 +76,6 @@
8376
namespace = 'v0:dialog',
8477
closeOnClickOutside = true,
8578
blocking = false,
86-
disableGlobalStack = false,
8779
} = defineProps<DialogContentProps>()
8880
8981
const emit = defineEmits<DialogContentEmits>()
@@ -93,16 +85,19 @@
9385
const contentRef = useTemplateRef('content')
9486
9587
// Register with global stack for z-index coordination
96-
const { styles, globalTop, zIndex } = useStack(context.isOpen, () => context.close(), {
88+
const stack = useStack()
89+
const ticket = stack.register({
90+
onDismiss: () => context.close(),
9791
blocking,
98-
disableGlobalStack,
9992
})
10093
101-
onMounted(() => {
102-
if (context.isOpen.value) {
103-
(contentRef.value?.element as HTMLDialogElement | undefined)?.showModal()
94+
watch(context.isOpen, isOpen => {
95+
if (isOpen) {
96+
ticket.select()
97+
} else {
98+
ticket.unselect()
10499
}
105-
})
100+
}, { immediate: true })
106101
107102
watch(context.isOpen, isOpen => {
108103
const element = contentRef.value?.element as HTMLDialogElement | undefined
@@ -115,6 +110,12 @@
115110
}
116111
})
117112
113+
onMounted(() => {
114+
if (context.isOpen.value) {
115+
(contentRef.value?.element as HTMLDialogElement | undefined)?.showModal()
116+
}
117+
})
118+
118119
useToggleScope(
119120
() => closeOnClickOutside && context.isOpen.value,
120121
/* v8 ignore start -- callback tested via useClickOutside */
@@ -138,10 +139,12 @@
138139
emit('close', e)
139140
}
140141
142+
const styles = toRef(() => ({ zIndex: ticket.zIndex.value }))
143+
141144
const slotProps = toRef((): DialogContentSlotProps => ({
142145
isOpen: context.isOpen.value,
143-
globalTop: globalTop.value,
144-
zIndex: zIndex.value,
146+
globalTop: ticket.globalTop.value,
147+
zIndex: ticket.zIndex.value,
145148
attrs: {
146149
'id': context.id,
147150
'role': 'dialog',

0 commit comments

Comments
 (0)