wire-elements/modal

Error when using dispatchCloseEvent on component

Closed this issue · 1 comments

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});
            }

Fixed in latest release