From bf56e15a2eed7d51199d5641649a822e91ca41ba Mon Sep 17 00:00:00 2001 From: Eugen Istoc Date: Thu, 5 Jun 2025 09:48:47 -0400 Subject: [PATCH] fix(useOverlay): use original props when not provided to `open` (#4269) --- src/runtime/composables/useOverlay.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/runtime/composables/useOverlay.ts b/src/runtime/composables/useOverlay.ts index 45c187d4..685b5220 100644 --- a/src/runtime/composables/useOverlay.ts +++ b/src/runtime/composables/useOverlay.ts @@ -17,6 +17,7 @@ interface ManagedOverlayOptionsPrivate { id: symbol isMounted: boolean isOpen: boolean + originalProps?: ComponentProps resolvePromise?: (value: any) => void } export type Overlay = OverlayOptions & ManagedOverlayOptionsPrivate @@ -26,7 +27,6 @@ type OverlayInstance = Omit open: (props?: ComponentProps) => OpenedOverlay close: (value?: any) => void patch: (props: Partial>) => void - } type OpenedOverlay = Omit, 'open' | 'close' | 'patch' | 'modelValue' | 'resolvePromise'> & { @@ -37,7 +37,7 @@ function _useOverlay() { const overlays = shallowReactive([]) const create = (component: T, _options?: OverlayOptions>): OverlayInstance => { - const { props: props, defaultOpen, destroyOnClose } = _options || {} + const { props, defaultOpen, destroyOnClose } = _options || {} const options = reactive({ id: Symbol(import.meta.dev ? 'useOverlay' : ''), @@ -45,7 +45,8 @@ function _useOverlay() { component: markRaw(component!), isMounted: !!defaultOpen, destroyOnClose: !!destroyOnClose, - props: props || {} + originalProps: props || {}, + props: {} }) overlays.push(options) @@ -64,6 +65,8 @@ function _useOverlay() { // If props are provided, update the overlay's props if (props) { patch(overlay.id, props) + } else { + patch(overlay.id, overlay.originalProps) } overlay.isOpen = true