feat: Add strict hierarchical breadcrumbs option - #20153
feat: Add strict hierarchical breadcrumbs option#20153ahmed-rashad-alnaggar wants to merge 8 commits into
Conversation
Signed-off-by: ahmed-rashad-alnaggar <131385452+ahmed-rashad-alnaggar@users.noreply.github.com>
Signed-off-by: ahmed-rashad-alnaggar <131385452+ahmed-rashad-alnaggar@users.noreply.github.com>
Signed-off-by: ahmed-rashad-alnaggar <131385452+ahmed-rashad-alnaggar@users.noreply.github.com>
Signed-off-by: ahmed-rashad-alnaggar <131385452+ahmed-rashad-alnaggar@users.noreply.github.com>
Signed-off-by: ahmed-rashad-alnaggar <131385452+ahmed-rashad-alnaggar@users.noreply.github.com>
|
Before this potentially gets merged, I wanted to float an idea for feedback. Right now Something like: $panel->strictHierarchicalNavigation(true);which Wanted to raise this in case it changes the shape of the API here — happy to rework this PR to fit that direction if it seems worth pursuing, or keep it scoped to breadcrumbs only if slugs should stay a separate concern. Let me know what you think. |
|
Just a heads up: I don't think I am going to have time to properly review and test this before the next minor release, which is very close to release already. |
|
Converting to draft to fix bugs regarding clusters and sub navigation. |
Add method to retrieve hierarchical breadcrumbs for clusters. Signed-off-by: ahmed-rashad-alnaggar <131385452+ahmed-rashad-alnaggar@users.noreply.github.com>
Signed-off-by: ahmed-rashad-alnaggar <131385452+ahmed-rashad-alnaggar@users.noreply.github.com>
Signed-off-by: ahmed-rashad-alnaggar <131385452+ahmed-rashad-alnaggar@users.noreply.github.com>
|
Fixed! |
Summary
Closes discussion #19515.
Adds an opt-in strict hierarchical breadcrumbs mode, configurable per-panel via
Panel::breadcrumbs():By default, breadcrumbs for a page are built from its resource and parent record relationships (e.g. an
EditRecordpage's breadcrumbs come from its resource's list/view pages, plus any parent resources for nested resources). When strict hierarchical mode is enabled, breadcrumbs are instead (additionally) built by walking the page's full navigational hierarchy — cluster ancestry, navigation group, and navigation parent item — and combining that chain with the existing resource/parent-record breadcrumbs.Changes
Filament\Panel\Concerns\HasBreadcrumbs: extendedbreadcrumbs()with a secondbool|Closure $strictHierarchical = falseparameter, and addedhasStrictHierarchicalBreadcrumbs()alongside the existinghasBreadcrumbs().Filament\Pages\Page: added$breadcrumbproperty,getBreadcrumb(), andgetHierarchicalBreadcrumbs(), which recursively resolves cluster, navigation group, and navigation parent item breadcrumbs for a page.getBreadcrumbs()now checksFilament::getCurrentOrDefaultPanel()->hasStrictHierarchicalBreadcrumbs()and prepends the hierarchical chain when enabled.Filament\Resources\Pages\Page:getResourceBreadcrumbs()now checks strict mode first and, when enabled, prependsstatic::getHierarchicalBreadcrumbs()ahead of the existing resource/parent-record breadcrumbs; falls back to the previous cluster-only behavior otherwise.Behavior
[...hierarchical chain, ...resource/parent-record breadcrumbs, page's own breadcrumb]. The hierarchical chain and resource/record breadcrumbs are combined, not one replacing the other.