Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

boyjarv's avatar

emit close event to close modal not working in a child component

Here is my modal:

<ModalWindow :open="isOpen" @close="this.isOpen = !this.isOpen">
      <AddEditForm
        :editing="isEdit"
        :contactDetails="contactDetails"
        :id="id"
      />
    </ModalWindow>

in my ModalWindow component I emit close and it closes, great!:

<AppButton type="close" @click="$emit('close')">Close</AppButton>

But say I wanted to $emit('close') from within my AddEditForm component, it doesn't close the modal?!

0 likes
1 reply
Niush's avatar

Yes, you need to handle manually.

<ModalWindow :open="isOpen" @close="closeModal()">
    <AddEditForm @close="closeModal()" />
</ModalWindow>

Please or to participate in this conversation.