wire-elements / modal

Livewire component that provides you with a modal that supports multiple child modals while maintaining state.
MIT License
1.12k stars 133 forks source link

Issue with closeModalWithEvents() #325

Closed michaeljhopkins closed 1 year ago

michaeljhopkins commented 1 year ago

I have this code in a modal

class EditAuthorizedUser extends ModalComponent {
    public function submit() {
        $this->closeModalWithEvents(['authorizedUsersUpdated']);
    }
}

and

class AuthorizedUsers extends Component {
    protected $listeners = ['authorizedUsersUpdated' => '$refresh'];
    public function render() {
        return view('view.file');
    }
}

When I close the modal I only see these events. What am I missing to make this method work?

Screenshot 2023-06-08 at 1 27 02 PM
feliperafael commented 1 year ago

I'm having the same issue. When I close the modal the event doesn't seem to fire. Did you get any solution?

lrljoe commented 1 year ago

Disable the destruction of the component.

It is destroying it before the event queue (internal to the component) has had a chance to run. In the config file, ensure its set to:

        'destroy_on_close' => false,