fix(useOverlay): improve types and docs (#4012)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Eugen Istoc
2025-04-29 12:09:39 -04:00
committed by GitHub
parent 195773ec7d
commit 39e29fccf1
3 changed files with 21 additions and 16 deletions

View File

@@ -504,7 +504,7 @@ const count = ref(0)
</script>
```
Closing a modal is now done through the `close` event. The `modal.open` method now returns a promise that resolves to the result of the modal whenever the modal is close:
Closing a modal is now done through the `close` event. The `modal.open` method now returns an instance that can be used to await for the result of the modal whenever the modal is closed:
```diff
<script setup lang="ts">
@@ -523,10 +523,12 @@ import { ModalExampleComponent } from '#components'
- })
- }
+ async function openModal() {
+ const result = await modal.open(ModalExampleComponent, {
+ const instance = modal.open(ModalExampleComponent, {
+ count: count.value
+ })
+
+ const result = await instance.result
+
+ if (result) {
+ toast.add({ title: 'Success!' })
+ }