From 357a621974972878f5794c0bb7b14162752419b7 Mon Sep 17 00:00:00 2001 From: Cole Shirley Date: Wed, 25 Sep 2024 07:46:38 -0500 Subject: [PATCH 1/3] remove other style changes --- .../src/Components/Concerns/HasState.php | 4 ++-- tests/src/Forms/StateTest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/forms/src/Components/Concerns/HasState.php b/packages/forms/src/Components/Concerns/HasState.php index 356d1439a63..5f020a9deae 100644 --- a/packages/forms/src/Components/Concerns/HasState.php +++ b/packages/forms/src/Components/Concerns/HasState.php @@ -192,8 +192,8 @@ public function dehydrateState(array &$state, bool $isDehydrated = true): void } } - foreach ($this->getChildComponentContainers() as $container) { - if ($container->isHidden()) { + foreach ($this->getChildComponentContainers(withHidden: true) as $container) { + if ($container->getParentComponent()?->isHiddenAndNotDehydrated()) { continue; } diff --git a/tests/src/Forms/StateTest.php b/tests/src/Forms/StateTest.php index a7bc9a96e56..f7acaa37a82 100644 --- a/tests/src/Forms/StateTest.php +++ b/tests/src/Forms/StateTest.php @@ -487,6 +487,25 @@ expect($container) ->dehydrateState()->not()->toBe([]); + + $container = ComponentContainer::make(Livewire::make()) + ->statePath('data') + ->components([ + (new Component) + ->id('parent') + ->hidden() + ->dehydratedWhenHidden() + ->childComponents([ + (new Component) + ->id('child') + ->statePath(Str::random()) + ->default(Str::random()), + ]), + ]) + ->fill(); + + expect($container) + ->dehydrateState()->not()->toBe([]); }); test('disabled components are excluded from state dehydration', function () { From 5630551828a808978b34638c502c7b2f47e9fae5 Mon Sep 17 00:00:00 2001 From: coleshirley Date: Wed, 25 Sep 2024 12:54:18 +0000 Subject: [PATCH 2/3] chore: fix code style --- packages/forms/resources/js/components/file-upload.js | 2 +- .../components/unsaved-action-changes-alert.blade.php | 8 +++++--- packages/tables/src/Filters/SelectFilter.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/forms/resources/js/components/file-upload.js b/packages/forms/resources/js/components/file-upload.js index 791a65148b8..7be09c507c4 100644 --- a/packages/forms/resources/js/components/file-upload.js +++ b/packages/forms/resources/js/components/file-upload.js @@ -247,7 +247,7 @@ export default function fileUploadFormComponent({ .map((file) => file.source instanceof File ? file.serverId - : this.uploadedFileIndex[file.source] ?? null, + : (this.uploadedFileIndex[file.source] ?? null), ) // file.serverId is null for a file that is not yet uploaded .filter((fileKey) => fileKey) diff --git a/packages/panels/resources/views/components/unsaved-action-changes-alert.blade.php b/packages/panels/resources/views/components/unsaved-action-changes-alert.blade.php index 2af3c05366d..60ac89013d7 100644 --- a/packages/panels/resources/views/components/unsaved-action-changes-alert.blade.php +++ b/packages/panels/resources/views/components/unsaved-action-changes-alert.blade.php @@ -8,11 +8,13 @@ if ( [ - ...(@js($this instanceof \Filament\Actions\Contracts\HasActions) ? $wire.mountedActions ?? [] : []), + ...(@js($this instanceof \Filament\Actions\Contracts\HasActions) ? ($wire.mountedActions ?? []) : []), ...(@js($this instanceof \Filament\Forms\Contracts\HasForms) - ? $wire.mountedFormComponentActions ?? [] + ? ($wire.mountedFormComponentActions ?? []) + : []), + ...(@js($this instanceof \Filament\Infolists\Contracts\HasInfolists) + ? ($wire.mountedInfolistActions ?? []) : []), - ...(@js($this instanceof \Filament\Infolists\Contracts\HasInfolists) ? $wire.mountedInfolistActions ?? [] : []), ...(@js($this instanceof \Filament\Tables\Contracts\HasTable) ? [ ...($wire.mountedTableActions ?? []), diff --git a/packages/tables/src/Filters/SelectFilter.php b/packages/tables/src/Filters/SelectFilter.php index 4b61d3d9ba6..4987b3da784 100644 --- a/packages/tables/src/Filters/SelectFilter.php +++ b/packages/tables/src/Filters/SelectFilter.php @@ -216,7 +216,7 @@ public function multiple(bool | Closure $condition = true): static } /** - * @param bool | array | Closure $condition + * @param bool | array | Closure $condition */ public function searchable(bool | array | Closure $condition = true): static { From 30a6bcdd1c4975bec1200e6eae8623eb361195b9 Mon Sep 17 00:00:00 2001 From: Cole Shirley Date: Mon, 7 Oct 2024 11:42:16 -0500 Subject: [PATCH 3/3] simplify hidden check --- packages/forms/src/Components/Concerns/HasState.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/forms/src/Components/Concerns/HasState.php b/packages/forms/src/Components/Concerns/HasState.php index 5f020a9deae..f33f1d57d6e 100644 --- a/packages/forms/src/Components/Concerns/HasState.php +++ b/packages/forms/src/Components/Concerns/HasState.php @@ -192,11 +192,11 @@ public function dehydrateState(array &$state, bool $isDehydrated = true): void } } - foreach ($this->getChildComponentContainers(withHidden: true) as $container) { - if ($container->getParentComponent()?->isHiddenAndNotDehydrated()) { - continue; - } + if ($this->isHiddenAndNotDehydrated()) { + return; + } + foreach ($this->getChildComponentContainers(withHidden: true) as $container) { $container->dehydrateState($state, $isDehydrated); } }