Skip to content

[4.x] Incorrect statePath resolution with deeply nested Layout Components in Infolists #18955

@alancolant

Description

@alancolant

Package

filament/filament

Package Version

v4.5.2

Laravel Version

v12.46.0

Livewire Version

v3.7.3

PHP Version

8.4.16

Problem description

There appears to be an issue with how statePath is resolved when using deeply nested Layout Components (e.g. Section, Grid, Group, etc.) inside Infolists.

When multiple layout components are nested and each defines its own statePath, the effective state resolution does not correctly compose all parent paths. In practice, only part of the parent hierarchy seems to be applied, even though the final component reports a fully qualified path via getStatePath().

This behavior is not specific to constantState, which is only used here to simplify reproduction, and not specific to Section. The same issue occurs with other layout components and across infolists in general.

The problem becomes especially visible in dynamic schemas (e.g. layouts generated from database definitions), where layouts may be nested arbitrarily.

Expected behavior

  • All nested Layout Components should correctly and consistently compose their statePath values.
  • The resolved state path used internally by the infolist should match the path returned by getStatePath().
  • Deep nesting should not cause parent statePath segments to be dropped or collapsed.
  • Behavior should be consistent regardless of whether the schema is static or dynamically generated.
  • constantState should not affect state resolution logic beyond providing initial data.

Steps to reproduce

  1. Create an infolist schema with a nested object state (using constantState only to provide test data):

    return $schema->constantState([
        'page' => [
            'block' => [
                'configuration' => [
                    'content' => 'Block configuration content',
                ],
            ],
        ],
    ])->components([
        Section::make('Page')
            ->statePath('page')
            ->schema([
                Section::make('Block')
                    ->statePath('block')
                    ->schema([
                        KeyValueEntry::make('configuration'),
                    ]),
            ]),
    ]);
  2. Observe that:

  • getStatePath() on the final entry returns the fully composed path (page.block.configuration).
  • getConstantStatePath() on the final entry only returns the immediate parent layout path (block.configuration), instead of the full absolute path.
  • As a result, the value is not consistently resolved from the infolist state.

Reproduction repository (issue will be closed if this is not valid)

https://github.com/alancolant/filament-nested-infolist-issue

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions