From 1dbbf6549a6ea3d46bcf033b97c34ef74a90234e Mon Sep 17 00:00:00 2001 From: Alperen Ersoy Date: Thu, 1 May 2025 21:42:53 +0300 Subject: [PATCH] added id check to modal closed event --- .../views/components/modals.blade.php | 20 +++++++++++++++++++ .../views/components/modal/index.blade.php | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/actions/resources/views/components/modals.blade.php b/packages/actions/resources/views/components/modals.blade.php index b095a76e0a..3c4440fb6a 100644 --- a/packages/actions/resources/views/components/modals.blade.php +++ b/packages/actions/resources/views/components/modals.blade.php @@ -27,6 +27,10 @@ :wire:key="$action ? $this->getId() . '.actions.' . $action->getName() . '.modal' : null" x-on:closed-form-component-action-modal.window="if (($event.detail.id === '{{ $this->getId() }}') && $wire.mountedActions.length) open()" x-on:modal-closed.stop=" + if ($event.detail.id !== '{{ $this->getId() }}-action') { + return + } + const mountedActionShouldOpenModal = {{ \Illuminate\Support\Js::from($action && $this->mountedActionShouldOpenModal(mountedAction: $action)) }} if (! mountedActionShouldOpenModal) { @@ -89,6 +93,10 @@ :wire:key="$action ? $this->getId() . '.table.actions.' . $action->getName() . '.modal' : null" x-on:closed-form-component-action-modal.window="if (($event.detail.id === '{{ $this->getId() }}') && $wire.mountedTableActions.length) open()" x-on:modal-closed.stop=" + if ($event.detail.id !== '{{ $this->getId() }}-table-action') { + return + } + const mountedTableActionShouldOpenModal = {{ \Illuminate\Support\Js::from($action && $this->mountedTableActionShouldOpenModal(mountedAction: $action)) }} if (! mountedTableActionShouldOpenModal) { @@ -145,6 +153,10 @@ :wire:key="$action ? $this->getId() . '.table.bulk-actions.' . $action->getName() . '.modal' : null" x-on:closed-form-component-action-modal.window="if (($event.detail.id === '{{ $this->getId() }}') && $wire.mountedTableBulkAction) open()" x-on:modal-closed.stop=" + if ($event.detail.id !== '{{ $this->getId() }}-table-bulk-action') { + return + } + const mountedTableBulkActionShouldOpenModal = {{ \Illuminate\Support\Js::from($action && $this->mountedTableBulkActionShouldOpenModal(mountedBulkAction: $action)) }} if (! mountedTableBulkActionShouldOpenModal) { @@ -207,6 +219,10 @@ :wire:key="$action ? $this->getId() . '.infolist.actions.' . $action->getName() . '.modal' : null" x-on:closed-form-component-action-modal.window="if (($event.detail.id === '{{ $this->getId() }}') && $wire.mountedInfolistActions.length) open()" x-on:modal-closed.stop=" + if ($event.detail.id !== '{{ $this->getId() }}-infolist-action') { + return + } + const mountedInfolistActionShouldOpenModal = {{ \Illuminate\Support\Js::from($action && $this->mountedInfolistActionShouldOpenModal(mountedAction: $action)) }} if (! mountedInfolistActionShouldOpenModal) { @@ -268,6 +284,10 @@ :width="$action?->getModalWidth()" :wire:key="$action ? $this->getId() . '.' . $action->getComponent()->getStatePath() . '.actions.' . $action->getName() . '.modal' : null" x-on:modal-closed.stop=" + if ($event.detail.id !== '{{ $this->getId() }}-form-component-action') { + return + } + const mountedFormComponentActionShouldOpenModal = {{ \Illuminate\Support\Js::from($action && $this->mountedFormComponentActionShouldOpenModal()) }} if (mountedFormComponentActionShouldOpenModal) { diff --git a/packages/support/resources/views/components/modal/index.blade.php b/packages/support/resources/views/components/modal/index.blade.php index 7a9fbe8ec7..4a2a642f42 100644 --- a/packages/support/resources/views/components/modal/index.blade.php +++ b/packages/support/resources/views/components/modal/index.blade.php @@ -72,7 +72,7 @@ this.isOpen = false this.$refs.modalContainer.dispatchEvent( - new CustomEvent('modal-closed', { id: '{{ $id }}' }), + new CustomEvent('modal-closed', { detail: { id: '{{ $id }}' } }), ) }, @@ -85,7 +85,7 @@ @endif this.$refs.modalContainer.dispatchEvent( - new CustomEvent('modal-opened', { id: '{{ $id }}' }), + new CustomEvent('modal-opened', { detail: { id: '{{ $id }}' } }), ) }) },