wire-elements / modal

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

Error when using dispatchCloseEvent on component #379

Closed tdondich closed 7 months ago

tdondich commented 8 months ago

When using livewire v3, if dispatchCloseEvent is true in the component, the following error occurs:

Only arrays and Traversables can be unpacked

This is because in modal.js, we have the following:

            if (this.getActiveComponentModalAttribute('dispatchCloseEvent') === true) {
                const componentName = this.$wire.get('components')[this.activeComponent].name;
                Livewire.dispatch('modalClosed', componentName);
            }

Note the old syntax of Livewire.dispatch. It should, ideally be refactored to:

            if (this.getActiveComponentModalAttribute('dispatchCloseEvent') === true) {
                const componentName = this.$wire.get('components')[this.activeComponent].name;
                Livewire.dispatch('modalClosed', {component: componentName});
            }
PhiloNL commented 7 months ago

Fixed in latest release