F
Filament4mo ago
shuvox

How to default a navigation group to collapsed on first load?

->navigationGroups([ NavigationGroup::make() ->label('Users') ->icon('heroicon‑o-users') ->collapsible() ]) I’m building an admin panel with a "Users" navigation group, which contains Roles, Permissions, and Users submenu items. However, whenever I first load the page, the group is always expanded by default—even if I haven’t clicked anything. I’d like the submenu to start collapsed (hidden), and only expand when the user clicks the group icon. 🙏 Would love to hear your approaches or insights here—thanks!
No description
Solution:
yeah, by modifying localstorage key collapsedGroups in render hook resolved the issue. Here is my updated code in panelprovider https://codeshare.io/5Od9Dr...
Jump to solution
2 Replies
Dennis Koch
Dennis Koch4mo ago
I think the state is loaded form localStorage so you’d need to overwrite that before Alpine initializes. You can either register a JS (not sure if that in time) or add some JS via a render hook
Solution
shuvox
shuvox4mo ago
yeah, by modifying localstorage key collapsedGroups in render hook resolved the issue. Here is my updated code in panelprovider https://codeshare.io/5Od9Dr

Did you find this page helpful?