|
26 | 26 | * @remarks When true, clicking the scrim will not dismiss this dialog. Use for critical dialogs requiring explicit user action. |
27 | 27 | */ |
28 | 28 | 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 |
36 | 29 | } |
37 | 30 |
|
38 | 31 | export interface DialogContentEmits { |
|
83 | 76 | namespace = 'v0:dialog', |
84 | 77 | closeOnClickOutside = true, |
85 | 78 | blocking = false, |
86 | | - disableGlobalStack = false, |
87 | 79 | } = defineProps<DialogContentProps>() |
88 | 80 |
|
89 | 81 | const emit = defineEmits<DialogContentEmits>() |
|
93 | 85 | const contentRef = useTemplateRef('content') |
94 | 86 |
|
95 | 87 | // 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(), |
97 | 91 | blocking, |
98 | | - disableGlobalStack, |
99 | 92 | }) |
100 | 93 |
|
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() |
104 | 99 | } |
105 | | - }) |
| 100 | + }, { immediate: true }) |
106 | 101 |
|
107 | 102 | watch(context.isOpen, isOpen => { |
108 | 103 | const element = contentRef.value?.element as HTMLDialogElement | undefined |
|
115 | 110 | } |
116 | 111 | }) |
117 | 112 |
|
| 113 | + onMounted(() => { |
| 114 | + if (context.isOpen.value) { |
| 115 | + (contentRef.value?.element as HTMLDialogElement | undefined)?.showModal() |
| 116 | + } |
| 117 | + }) |
| 118 | +
|
118 | 119 | useToggleScope( |
119 | 120 | () => closeOnClickOutside && context.isOpen.value, |
120 | 121 | /* v8 ignore start -- callback tested via useClickOutside */ |
|
138 | 139 | emit('close', e) |
139 | 140 | } |
140 | 141 |
|
| 142 | + const styles = toRef(() => ({ zIndex: ticket.zIndex.value })) |
| 143 | +
|
141 | 144 | const slotProps = toRef((): DialogContentSlotProps => ({ |
142 | 145 | isOpen: context.isOpen.value, |
143 | | - globalTop: globalTop.value, |
144 | | - zIndex: zIndex.value, |
| 146 | + globalTop: ticket.globalTop.value, |
| 147 | + zIndex: ticket.zIndex.value, |
145 | 148 | attrs: { |
146 | 149 | 'id': context.id, |
147 | 150 | 'role': 'dialog', |
|
0 commit comments