ui icon indicating copy to clipboard operation
ui copied to clipboard

Programmatically opening Modal form within an opened Slideover does not work.

Open francois-duquesne-asl opened this issue 1 year ago • 10 comments

Description

Hey!

Not sure if this is a bug or a malpractice from my side.

I have my ModalComponent.vue and y SlideOverComponent.vue as separate components that I mould like to open programmatically.

First the user should open the slideover. Then, inside the slideover the user clicks on a button that should trigger the modal to open. However, this does not work, and I wonder why. This works fine when the components are not opened programmatically but with an isOpen value (so in the same file).

Minimal reproduction env: https://stackblitz.com/edit/github-olfzub?file=app.vue

My example code:

  • pages/test-page.vue
<script setup lang="ts">
import { SlideOverComponent } from "#components";
const modal = useModal();
</script>

<template>
  <div>
    <UButton label="Open" @click="modal.open(SlideOverComponent)" />
  </div>
</template>
  • SlideOverComponent.vue
<script setup lang="ts">
import { ModalComponent } from "#components";
const modal = useModal();
</script>

<template>
  <USlideover>
    <UButton label="Open" @click="modal.open(ModalComponent)" />
  </USlideover>
</template>
  • ModalComponent.vue
<template>
  <UModal> OKOK </UModal>
</template>

francois-duquesne-asl avatar Aug 14 '24 09:08 francois-duquesne-asl

Did you correctly add <UModals /> somewhere in your app, preferably in app.vue ?

noook avatar Aug 14 '24 12:08 noook

Yep. The other modals I open programmatically work just fine.

In my app.vue

<template>
  <div>
    <NuxtLayout>
      <NuxtPage />
    </NuxtLayout>
    <UNotifications />
    <USlideovers />
    <UModals />
  </div>
</template>

Could the order of USlideovers and UModals have an impact?

francois-duquesne-asl avatar Aug 14 '24 12:08 francois-duquesne-asl

I am wondering. Could you provide a link to a reproduction ? Could be a z-index conflict maybe, do you know if your modal appears in the dom, or does it log something when being mounted ?

noook avatar Aug 14 '24 12:08 noook

So, the modal does indeed log something on mounted but seems to disappear just after. When I click on the trigger btn for the modal, the #headlessui-portal-root div (that was present for the sidepanel) disappears. It feels like the new modal is in conflict with the slideover, they both seem to use the #headlessui-portal-root div.

I tried adding prevent-close prop to the USlideover but this did not change the output.

francois-duquesne-asl avatar Aug 14 '24 13:08 francois-duquesne-asl

I do think this is a bug... Can I (or someone) change the label, or should I create a new issue?

francois-duquesne-asl avatar Aug 19 '24 13:08 francois-duquesne-asl

I labeled it as a bug. If you could provide a minimal reproduction it would be awesome.

noook avatar Aug 19 '24 13:08 noook

Thx! Here is a stackblitz env: https://stackblitz.com/edit/github-olfzub?file=app.vue

I am not too familiar with stackblitz but I did manage to reproduce the bug, hope it works fine for you. 👍

So, to recap:

  • ✅ clicking on the "open SlideOver" btn works fine,
  • ✅ clicking on the "open Modal" btn works fine.
  • ❌ clicking on the "open SlideOver" btn then on the "open Modal" btn inside the slideover is when the bug occurs.

francois-duquesne-asl avatar Aug 19 '24 16:08 francois-duquesne-asl

Got the same error if there are two modals on the page, which I open/close programmatically.

ahoiroman avatar Aug 20 '24 14:08 ahoiroman

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Sep 20 '24 01:09 github-actions[bot]

I have got something similiar. Opening the slideover first and click on a button that opens the modal it overlaps just fine. But if I want to close the modal by clicking outside or modal.close it appears that it also closes the slideover or even closes the slideover first and after a second click on close it closes the modal. very strange.

for reproduction:

umodals and uslideovers in app.vue open a slideover that contains a button that opens a modal open the modal

expected behavior: both the slideover and the modal are showing and overlap. when clicking outside the modal it should close the modal and keep the slideover open but thats not the case

schillerenrico avatar Sep 30 '24 10:09 schillerenrico

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Nov 28 '24 02:11 github-actions[bot]

@francois-duquesne-asl Are you able to test this issue with this PR: #3279

It should solve this issue.

genu avatar Feb 13 '25 20:02 genu

@genu fyi this was in nuxt ui 2 looked solved in nuxt ui 3 :)

schillerenrico avatar Feb 13 '25 20:02 schillerenrico

I m currently on holliday, and won't be able to test this before the 19th of february. I can do it then if still required.

Thx for the work.

francois-duquesne-asl avatar Feb 14 '25 01:02 francois-duquesne-asl