@@ -58,6 +58,16 @@ abstract class Page extends BasePage
5858
5959 protected static bool $ shouldRegisterNavigation = true ;
6060
61+ /**
62+ * @var array<Component | Action | ActionGroup>
63+ */
64+ protected array $ cachedHeaderWidgetsSchemaComponents ;
65+
66+ /**
67+ * @var array<Component | Action | ActionGroup>
68+ */
69+ protected array $ cachedFooterWidgetsSchemaComponents ;
70+
6171 protected string $ view = 'filament-panels::pages.page ' ;
6272
6373 public function getLayout (): string
@@ -387,10 +397,10 @@ public function headerWidgets(Schema $schema): Schema
387397 ->components ([
388398 RenderHook::make (PanelsRenderHook::PAGE_HEADER_WIDGETS_START ),
389399 Grid::make ($ this ->getHeaderWidgetsColumns ())
390- ->schema ($ widgets = $ this ->getWidgetsSchemaComponents ($ this ->getHeaderWidgets ())),
400+ ->schema (fn (): array => $ this -> cachedHeaderWidgetsSchemaComponents ?? = $ this ->getWidgetsSchemaComponents ($ this ->getHeaderWidgets ())),
391401 RenderHook::make (PanelsRenderHook::PAGE_HEADER_WIDGETS_END ),
392402 ])
393- ->hidden (empty ($ widgets ));
403+ ->hidden (fn (): bool => empty ($ this -> cachedHeaderWidgetsSchemaComponents ??= $ this -> getWidgetsSchemaComponents ( $ this -> getHeaderWidgets ()) ));
394404 }
395405
396406 public function footerWidgets (Schema $ schema ): Schema
@@ -399,10 +409,10 @@ public function footerWidgets(Schema $schema): Schema
399409 ->components ([
400410 RenderHook::make (PanelsRenderHook::PAGE_FOOTER_WIDGETS_START ),
401411 Grid::make ($ this ->getFooterWidgetsColumns ())
402- ->schema ($ widgets = $ this ->getWidgetsSchemaComponents ($ this ->getFooterWidgets ())),
412+ ->schema (fn (): array => $ this -> cachedFooterWidgetsSchemaComponents ?? = $ this ->getWidgetsSchemaComponents ($ this ->getFooterWidgets ())),
403413 RenderHook::make (PanelsRenderHook::PAGE_FOOTER_WIDGETS_END ),
404414 ])
405- ->hidden (empty ($ widgets ));
415+ ->hidden (fn (): bool => empty ($ this -> cachedFooterWidgetsSchemaComponents ??= $ this -> getWidgetsSchemaComponents ( $ this -> getFooterWidgets ()) ));
406416 }
407417
408418 public function getDefaultTestingSchemaName (): ?string
0 commit comments