Closed Aravinda93 closed 5 months ago
I got the same exact issue in headlessui/react v2+ now.
@boring-joey
I solved it by placing the DialogPanel2.vue inside the DialogPanel1.vue:
<TransitionRoot appear :show="modal1" as="template" @close="closeModal">
<Dialog as="div" class="relative z-30">
<div class="fixed inset-0 overflow-y-auto">
<div
class="flex min-h-full items-center justify-center p-4 text-center"
>
<DialogPanel
class="dark:bg-slate-800 w-full transform overflow-auto rounded-2xl bg-gray-200 p-6 text-left align-middle shadow-xl transition-all z-20"
>
THIS IS MODAL-1
<button
class="flex secondary-button text-secondary dark:bg-transparent dark:hover:text-secondary dark:hover:bg-slate-700 mx-auto justify-center items-center rounded border focus:ring-0 focus:outline-none font-medium px-5 py-2.5 text-center min-w-[8rem] sm:min-w-[10rem] lg:min-w-[12rem]"
@click="openModal2"
>
MODAL-2
</button>
<DialogPanel2 :modal2="modal2" @closeModal="hideModal2" /><!-- move it here-->
</DialogPanel>
</div>
</div>
</Dialog>
</TransitionRoot>
This issue is still happening. I've opened an issue in Nuxt ui: https://github.com/nuxt/ui/issues/2431
In my case i need only 1 Modal to show Pricing in the page, but sometimes another modal opens this modal, so i can't to add inside of other modals. Also some features are paid in my web, so i cannot add 3 times this modal in the same Page.
@RobinMalfait
I am using the
HeadlessUI/Vue
component in myNuxt 3
application to build the Dialog/Modals. I am using the latest version"@headlessui/vue": "^1.7.22"
and developing in Chrome latest browser.Minimal reproduction repo in CodeSandBox
I am creating a
DialogPanel1.vue
using theheadlessui/vue
. I have a button inDialogPanel1.vue
on clicking it I am opening theDialogPanel2.vue
but withinDialogPanel2.vue
when I click anywhere then it automatically closes theDialogPanel1.vue
which is behind theDialogPanel2.vue
.Why is it closing
DialogPanel1
automatically? I want to ensure thatDialogPanel1
is closed only when I click the close button inDialogPanel1.vue
not for any click onDialogPanel2
. I tried adding the@click.stop
or@mousedown.stop
to prevent the propagation of the event but it's still not working. Can anyone please let me know the issue?Following is my complete code
/pages/Test.vue
:Following are my components
/component/DialogPanel1.vue
:Following is my
/components/DialogPanel2.vue
:Why clicking anywhere on
DialogPanel2.vue
automatically closes the previous DialogDialogPanel1.vue
?Following issue my issue GIF: