diff --git a/docs/app/components/content/examples/modal/ModalProgrammaticExample.vue b/docs/app/components/content/examples/modal/ModalProgrammaticExample.vue index 7db15eb9..e54fa0ea 100644 --- a/docs/app/components/content/examples/modal/ModalProgrammaticExample.vue +++ b/docs/app/components/content/examples/modal/ModalProgrammaticExample.vue @@ -13,7 +13,9 @@ const modal = overlay.create(LazyModalExample, { }) async function open() { - const shouldIncrement = await modal.open() + const instance = modal.open() + + const shouldIncrement = await instance.result if (shouldIncrement) { count.value++ diff --git a/docs/app/components/content/examples/slideover/SlideoverProgrammaticExample.vue b/docs/app/components/content/examples/slideover/SlideoverProgrammaticExample.vue index 3a526f1e..0e37145d 100644 --- a/docs/app/components/content/examples/slideover/SlideoverProgrammaticExample.vue +++ b/docs/app/components/content/examples/slideover/SlideoverProgrammaticExample.vue @@ -13,7 +13,9 @@ const slideover = overlay.create(LazySlideoverExample, { }) async function open() { - const shouldIncrement = await slideover.open() + const instance = slideover.open() + + const shouldIncrement = await instance.result if (shouldIncrement) { count.value++ diff --git a/docs/content/2.composables/use-overlay.md b/docs/content/2.composables/use-overlay.md index 2be6198a..d8c7fb46 100644 --- a/docs/content/2.composables/use-overlay.md +++ b/docs/content/2.composables/use-overlay.md @@ -66,6 +66,13 @@ Update an overlay using its `id` Removes the overlay from the DOM using its `id` +- Parameters: + - `id`: The identifier of the overlay + +### `isOpen(id: symbol): boolean` + +Checks if an overlay its open using its `id` + - Parameters: - `id`: The identifier of the overlay diff --git a/src/runtime/composables/useOverlay.ts b/src/runtime/composables/useOverlay.ts index cb6e4d52..43ce9ace 100644 --- a/src/runtime/composables/useOverlay.ts +++ b/src/runtime/composables/useOverlay.ts @@ -122,6 +122,12 @@ function _useOverlay() { return overlay } + const isOpen = (id: symbol): boolean => { + const overlay = getOverlay(id) + + return overlay.isOpen + } + return { overlays, open, @@ -129,7 +135,8 @@ function _useOverlay() { closeAll, create, patch, - unMount + unMount, + isOpen } }