From 1dbbf6549a6ea3d46bcf033b97c34ef74a90234e Mon Sep 17 00:00:00 2001 From: Alperen Ersoy Date: Thu, 1 May 2025 21:42:53 +0300 Subject: [PATCH 1/3] 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 }}' } }), ) }) }, From 6aeeba300539e6703138c4ba790bc1c8dd574c23 Mon Sep 17 00:00:00 2001 From: Alperen Ersoy Date: Mon, 2 Jun 2025 21:51:52 +0300 Subject: [PATCH 2/3] used starts with for modal closed event id check instead of exact match --- .../resources/views/components/modals.blade.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/actions/resources/views/components/modals.blade.php b/packages/actions/resources/views/components/modals.blade.php index 3c4440fb6a..d7118f7951 100644 --- a/packages/actions/resources/views/components/modals.blade.php +++ b/packages/actions/resources/views/components/modals.blade.php @@ -27,7 +27,7 @@ :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') { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}')) { return } @@ -93,7 +93,7 @@ :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') { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}')) { return } @@ -153,7 +153,7 @@ :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') { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}')) { return } @@ -219,7 +219,7 @@ :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') { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}')) { return } @@ -284,7 +284,7 @@ :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') { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}')) { return } From 1253dde2892313c331e0ec7afa1abd8916829f17 Mon Sep 17 00:00:00 2001 From: Alperen Ersoy Date: Mon, 2 Jun 2025 22:00:32 +0300 Subject: [PATCH 3/3] added trailing dash to id check in modal closed event --- .../resources/views/components/modals.blade.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/actions/resources/views/components/modals.blade.php b/packages/actions/resources/views/components/modals.blade.php index d7118f7951..b2bb5f1300 100644 --- a/packages/actions/resources/views/components/modals.blade.php +++ b/packages/actions/resources/views/components/modals.blade.php @@ -27,7 +27,7 @@ :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?.startsWith('{{ $this->getId() }}')) { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}-')) { return } @@ -93,7 +93,7 @@ :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?.startsWith('{{ $this->getId() }}')) { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}-')) { return } @@ -153,7 +153,7 @@ :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?.startsWith('{{ $this->getId() }}')) { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}-')) { return } @@ -219,7 +219,7 @@ :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?.startsWith('{{ $this->getId() }}')) { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}-')) { return } @@ -284,7 +284,7 @@ :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?.startsWith('{{ $this->getId() }}')) { + if (!$event.detail?.id?.startsWith('{{ $this->getId() }}-')) { return }