-
Notifications
You must be signed in to change notification settings - Fork 711
feat(useOverlay)!: handle programmatic modals and slideovers #3279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There are some APIs missing at this point until I get initial feedback on this design. |
β¦nd streamline modal instance creation
β¦ and useManagedOverlay functions
β¦into feature/useOverlayManager
β¦der and streamline overlay management
β¦into feature/useOverlayManager
It seems that The new Edit: let me know your thoughts. |
β¦ric `useOverlayInstance`
β¦into feature/useOverlayManager
β¦integrating managedOverlay
β¦managedOverlay and pop function
β¦into feature/useOverlayManager
Thanks @genu! π |
also |
OverlayProvider.vue is missing and useOverlay.js is missing |
Damn it, just released |
sorry :( - i also commented on ur last commit about it and tagged you! |
|
e.g:
I didn't get the correct props type when using useOverlay, and there are no property hints when passing overlay.open or the open function after create |
Could you please create a reproduction, and create a separate issue for this. |
Ok, I have resubmitted it. #3436 |
How one catch
How would I catch |
When opening programmatic modals, only a single event can be emitted. This is because an overlay is assumed to either return something or nothing. This is by design. In your case, the way you would do it is: const modal = overlay.create(AvatarCropperModal, {
props: {
avatar: avatar.value,
},
})
const modalResult = await modal.open()
// Perform any operation you want with the result. The important thing to remember is that your See the example here: https://ui3.nuxt.dev/composables/use-overlay#example |
okay just a heads up, it was indeed working with: await modal.open({
avatar: avatar.value,
onAvatarUpdated: () => ...
}) But I decided to pass data through close emit since it doesn't matter for me. Now why I can't submit form which lies inside a modal, is this somehow related?? <UModal v-model:open="isLanguageModalOpen">
<UButton icon="i-heroicons-plus-circle" />
<template #content>
<UForm :schema="knownLanguageSchema" :state="modalState" @submit.prevent="onAddNewLanguage">
<UFormField name="newLanguage">
<USelectMenu v-model="modalState.newLanguage" :items="languages" value-key="code" label-key="name" />
</UFormField>
<UFormField name="motherTongue">
<UCheckbox v-model="modalState.motherTongue" />
</UFormField>
<div class="flex gap-4 items-center">
<UButton type="submit" />
<UButton @click="onCancelNewLanguage" />
</div>
</UForm>
</template>
</UModal> when I submit this form using a button |
The submission issue might be unrelated. Do note, however, that with dynamic modals, you shouldn't add If you still have issues, please open up a new issue with a reproduction. |
Co-authored-by: Benjamin Canac <[email protected]>
Related Issue
Related Discussion: #1758
Should fix these issues:
Resolves #2041
Resolves #2777
Resolves #2799
Resolves #3157
β Type of change
π Description
@benjamincanac This is an ambitious PR from previous conversations that we had around
slideovers
andmodals
.It tries to address two things that came up in the past. Perhaps its best to address them before v3 is released:
slideover
andmodal
is essentially the same.useOverlay
Introduced to manage the
modals
andslideovers
that are createduseOverlay().create(...)
It essentially does the same thing that
useSlideover
anduseModal
did, but its more generic. It takes any component and exposes:open
close
patch
useOverlayInstance()
Used to inject the instance of an overlay. This would be useful to allow allow a instantiated overlay to also programmatically also perform actions on itself (e.g. close itself)
Under the hood
useOverlay
manages the overlays,mount/unmount
components, and handle the stacking of the components (i.e. nesting)Looking forward to some feedback.
The API change would now look like this:
π Checklist