@@ -36,6 +36,7 @@ const props = withDefaults(
3636 footer? : boolean
3737 closeOnClickOverlay? : boolean
3838 closeOnPressEscape? : boolean
39+ destroyOnClose? : boolean
3940 contentClass? : HTMLAttributes [' class' ]
4041 headerClass? : HTMLAttributes [' class' ]
4142 footerClass? : HTMLAttributes [' class' ]
@@ -59,6 +60,7 @@ const props = withDefaults(
5960 footer: true ,
6061 closeOnClickOverlay: true ,
6162 closeOnPressEscape: true ,
63+ destroyOnClose: true ,
6264 },
6365)
6466
@@ -81,6 +83,20 @@ watch(() => props.modelValue, (newValue) => {
8183 isOpen .value = newValue
8284})
8385
86+ const hasOpened = ref (false )
87+ const isClosed = ref (true )
88+
89+ watch (() => isOpen .value , (value ) => {
90+ isClosed .value = false
91+ if (value && ! hasOpened .value ) {
92+ hasOpened .value = true
93+ }
94+ }, {
95+ immediate: true ,
96+ })
97+
98+ const forceMount = computed (() => ! props .destroyOnClose && hasOpened .value )
99+
84100function updateOpen(value : boolean ) {
85101 isOpen .value = value
86102 emits (' update:modelValue' , value )
@@ -127,6 +143,7 @@ function handleAnimationEnd() {
127143 }
128144 else {
129145 emits (' closed' )
146+ isClosed .value = true
130147 }
131148}
132149 </script >
@@ -138,8 +155,11 @@ function handleAnimationEnd() {
138155 :open =" isOpen"
139156 :overlay =" props.overlay"
140157 :overlay-blur =" props.overlayBlur"
141- :class =" cn('w-full flex flex-col gap-0 p-0', props.contentClass)"
158+ :class =" cn('w-full flex flex-col gap-0 p-0', props.contentClass, {
159+ hidden: isClosed,
160+ })"
142161 :side =" props.side"
162+ :force-mount =" forceMount"
143163 @open-auto-focus =" handleFocusOutside"
144164 @close-auto-focus =" handleFocusOutside"
145165 @focus-outside =" handleFocusOutside"
0 commit comments