Collapsible Navigation Groups Implementation

📄 General
← Back to Documentation
# Collapsible Navigation Groups Implementation ## Overview Added collapsible navigation groups functionality to all Filament panels. When one navigation group is opened, others will automatically close, providing a cleaner and more organized sidebar experience. ## Changes Made ### 1. Admin Panel **File:** `app/Providers/Filament/AdminPanelProvider.php` Added `->collapsibleNavigationGroups()` to the panel configuration: ```php return $panel ->defaultThemeMode(ThemeMode::Light) ->default() ->id('admin') ->path('admin') ->login() ->sidebarCollapsibleOnDesktop() ->collapsibleNavigationGroups() // ✅ Added ->simpleProfilePage() ->databaseNotifications() // ... rest of configuration ``` ### 2. App Panel **File:** `app/Providers/Filament/AppPanelProvider.php` Added both `->sidebarCollapsibleOnDesktop()` and `->collapsibleNavigationGroups()`: ```php return $panel ->id('app') ->path('app') ->login() ->sidebarCollapsibleOnDesktop() // ✅ Added ->collapsibleNavigationGroups() // ✅ Added ->colors([ 'primary' => Color::Emerald, ]) // ... rest of configuration ``` ### 3. Client Panel **File:** `app/Providers/Filament/ClientPanelProvider.php` Added `->collapsibleNavigationGroups()` and cleaned up duplicate `->sidebarCollapsibleOnDesktop()`: ```php return $panel ->id('client') ->path('client') ->login(ClientLoginScreenPage::class) ->colors([ 'primary' => Color::Blue, ]) ->spa() ->sidebarCollapsibleOnDesktop(true) ->collapsibleNavigationGroups() // ✅ Added ->profile() ->databaseNotifications() ->databaseNotificationsPolling('30s') // ... rest of configuration ``` ## How It Works ### Before - All navigation groups were expanded by default - Multiple groups could be open simultaneously - Sidebar could become cluttered with many resources ### After - Navigation groups can be collapsed/expanded by clicking on them - Opening one group automatically closes others (accordion behavior) - Cleaner, more organized sidebar navigation - Better user experience, especially with many navigation groups ## Navigation Groups in the Application The application uses several navigation groups to organize resources: ### Admin Panel Groups - **Bookings** - Booking management resources - **Finance** - Invoices, payments, transactions - **Venues** - Venue, venue objects, spots, facilities - **Services** - Services and packages - **Products** - Products and product types - **Clients** - Client management - **Users** - User and operator management - **Settings** - Configuration pages - **Administration** - System administration ### App Panel Groups - **Master Data** - Companies, workspaces, locations - **Configuration** - Types, currencies, settings - **Services** - Service definitions - **Packages** - Package definitions ### Client Panel Groups - **My Account** - Client profile and preferences - **My Bookings** - Reservations and bookings - **My Finances** - Invoices and payments - **My Activity** - Reviews, favorites, bonuses ## Benefits ### 1. Improved Navigation - Cleaner sidebar with less visual clutter - Easier to find specific resources - Better organization of related items ### 2. Better UX - Accordion-style behavior is familiar to users - Reduces scrolling in long navigation menus - Maintains focus on current working area ### 3. Scalability - Handles applications with many resources better - Groups can contain many items without overwhelming the UI - Easy to add new resources without cluttering navigation ## Testing To test the collapsible navigation groups: 1. **Clear cache:** ```bash php artisan filament:cache-components php artisan optimize:clear ``` 2. **Access any panel:** - Admin: `/admin` - App: `/app` - Client: `/client` 3. **Test navigation:** - Click on a navigation group to expand it - Click on another group - the first should collapse - Only one group should be open at a time - Clicking the same group again should collapse it ## Additional Configuration Options ### Keep Multiple Groups Open If you want to allow multiple groups to stay open (not accordion behavior), you can use: ```php ->collapsibleNavigationGroups(false) ``` ### Default Collapsed State To have all groups collapsed by default, resources can specify: ```php protected static bool $shouldRegisterNavigation = true; protected static ?int $navigationSort = 1; protected static bool $isCollapsed = true; // Start collapsed ``` ### Individual Group Behavior You can control individual group behavior in resources: ```php public static function getNavigationGroup(): ?string { return __('Finance'); } public static function shouldRegisterNavigation(): bool { return true; } ``` ## Compatibility - ✅ Filament v4.x - ✅ Works with all panel types (Admin, App, Client) - ✅ Compatible with SPA mode - ✅ Works with sidebar collapsible on desktop - ✅ Compatible with top navigation (if enabled) ## Related Settings These panel methods work together for optimal navigation: ```php ->sidebarCollapsibleOnDesktop() // Collapse entire sidebar ->collapsibleNavigationGroups() // Collapse individual groups ->sidebarWidth('20rem') // Custom sidebar width ->maxContentWidth('full') // Full content width ->spa() // Single page application mode ``` ## Summary The collapsible navigation groups feature has been successfully implemented across all three Filament panels (Admin, App, and Client). This provides a cleaner, more organized navigation experience with accordion-style behavior where opening one group automatically closes others. **Key Changes:** - ✅ Admin Panel - Added `collapsibleNavigationGroups()` - ✅ App Panel - Added `sidebarCollapsibleOnDesktop()` and `collapsibleNavigationGroups()` - ✅ Client Panel - Added `collapsibleNavigationGroups()` and cleaned up duplicates **Result:** Better UX with organized, collapsible navigation groups that automatically close when another is opened.