Skip to content

Commit

Permalink
Fix issues when a nested action is called without a modal
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Feb 2, 2025
1 parent 043363d commit 9e4595b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
12 changes: 6 additions & 6 deletions docs-assets/app/public/js/filament/support/support.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion packages/actions/src/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,12 @@ public function getLivewireCallMountedActionName(): string
return 'callMountedAction';
}

protected function getJavaScriptClickHandler(): string
protected function getJavaScriptClickHandler(): ?string
{
if ($this->shouldClose()) {
return null;
}

$argumentsParameter = '';

if (count($arguments = $this->getArguments())) {
Expand Down
4 changes: 2 additions & 2 deletions packages/actions/src/Concerns/InteractsWithActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ public function mountAction(string $name, array $arguments = [], array $context
return null;
}

$this->syncActionModals();

if (($actionComponent = $action->getSchemaComponent()) instanceof ExposesStateToActionData) {
foreach ($actionComponent->getChildComponentContainers() as $actionComponentChildComponentContainer) {
$actionComponentChildComponentContainer->validate();
Expand Down Expand Up @@ -149,6 +147,8 @@ public function mountAction(string $name, array $arguments = [], array $context
return $this->callMountedAction();
}

$this->syncActionModals();

$this->resetErrorBag();

return null;
Expand Down
12 changes: 6 additions & 6 deletions packages/support/dist/index.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions packages/support/resources/js/components/modal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default ({ id }) => ({
isOpen: false,

isModalWindowVisible: false,
isWindowVisible: false,

livewire: null,

Expand All @@ -10,12 +10,12 @@ export default ({ id }) => ({
if (this.isOpen) {
this.$root?.showModal()

this.isModalWindowVisible = true
this.isWindowVisible = true

return;
}

this.isModalWindowVisible = false
this.isWindowVisible = false

setTimeout(
() => this.$root?.close(),
Expand All @@ -27,6 +27,10 @@ export default ({ id }) => ({
close: function () {
this.closeQuietly()

this.$refs.windowContainer?.dispatchEvent(
new CustomEvent('modal-closing', { id }),
)

setTimeout(
() => this.$refs.windowContainer?.dispatchEvent(
new CustomEvent('modal-closed', { id }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
>
<div
aria-hidden="true"
x-show="isModalWindowVisible"
x-show="isWindowVisible"
x-transition.duration.300ms.opacity
class="fi-modal-close-overlay"
></div>
Expand All @@ -119,7 +119,7 @@ class="fi-modal-close-overlay"
]) }}
>
<div
x-show="isModalWindowVisible"
x-show="isWindowVisible"
x-ref="window"
@if ($closeByEscaping)
x-on:keydown.window.escape="{{ $closeEventHandler }}"
Expand Down

0 comments on commit 9e4595b

Please sign in to comment.