mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge pull request #16419 from alanost/test/dehydration-issues-section
Hidden fields in Section incorrectly dehydrated in Section with state path
This commit is contained in:
@@ -189,7 +189,7 @@ trait HasState
|
||||
// we need to dehydrate the child component containers while
|
||||
// informing them that they are not dehydrated, so that their
|
||||
// child components get removed from the state.
|
||||
foreach ($this->getChildComponentContainers() as $container) {
|
||||
foreach ($this->getChildComponentContainers(withHidden: true) as $container) {
|
||||
$container->dehydrateState($state, isDehydrated: false);
|
||||
}
|
||||
|
||||
|
||||
@@ -599,6 +599,28 @@ test('hidden components are not excluded from state dehydration if there is anot
|
||||
->dehydrateState()->data->not()->toBe([]);
|
||||
});
|
||||
|
||||
test('components in a hidden parent component with a grandparent component with a state path are excluded from state dehydration', function () {
|
||||
$container = ComponentContainer::make(Livewire::make())
|
||||
->statePath('data')
|
||||
->components([
|
||||
(new Component)
|
||||
->statePath('data')
|
||||
->schema([
|
||||
(new Component)
|
||||
->schema([
|
||||
(new Component)
|
||||
->statePath(Str::random())
|
||||
->default(Str::random()),
|
||||
])
|
||||
->hidden(),
|
||||
]),
|
||||
])
|
||||
->fill();
|
||||
|
||||
expect($container)
|
||||
->dehydrateState()->toBe(['data' => ['data' => []]]);
|
||||
});
|
||||
|
||||
test('disabled components are excluded from state dehydration', function () {
|
||||
$container = ComponentContainer::make(Livewire::make())
|
||||
->statePath('data')
|
||||
|
||||
Reference in New Issue
Block a user