© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
Jon Mason

re-render sidebar when item is selected

I'm probably doing this wrong by putting it in the boot method, but I have a dropdown in the topbar that sets a value in the session. Whenever that changes, or is cleared, I want the sidebar to refresh.

I'm doing this in the boot menu, which is likely not right as it's only running once, but I tried adding a render method and didn't make a difference.

    protected $selectedLocationId = false;
    protected $selectedLocationName = false;

    public function boot()
    {
             $selectedLocation = Session::get('selectedLocation');
            if (!empty($selectedLocation)) {
                $this->selectedLocationId = $selectedLocation->id;
                $this->selectedLocationName = $selectedLocation->name;
            }
    }
    protected $selectedLocationId = false;
    protected $selectedLocationName = false;

    public function boot()
    {
             $selectedLocation = Session::get('selectedLocation');
            if (!empty($selectedLocation)) {
                $this->selectedLocationId = $selectedLocation->id;
                $this->selectedLocationName = $selectedLocation->name;
            }
    }


And then I'm trying to add this navigation that should change based on the selection:

->navigationGroups([
                NavigationGroup::make()
                    ->label(function () {
                        return $this->selectedLocationName;
                    })
                    ->collapsed()
            ])
            ->navigationItems([
                NavigationItem::make('details')
                    ->label('Details')
                    ->visible($this->selectedLocationId ?? false)
                    ->url(function () {
                        if ($this->selectedLocationId) {
                            return LocationResource::getUrl('details', ['record' => $this->selectedLocationId]);
                        } else {
                            return false;
                        }
                    }),
->navigationGroups([
                NavigationGroup::make()
                    ->label(function () {
                        return $this->selectedLocationName;
                    })
                    ->collapsed()
            ])
            ->navigationItems([
                NavigationItem::make('details')
                    ->label('Details')
                    ->visible($this->selectedLocationId ?? false)
                    ->url(function () {
                        if ($this->selectedLocationId) {
                            return LocationResource::getUrl('details', ['record' => $this->selectedLocationId]);
                        } else {
                            return false;
                        }
                    }),


Also, I have database notifications enabled, so I see the update in the network tab in dev tools happening every few seconds or so, but when I do a
Log::debug()
Log::debug()
from the boot method, it puts log entries like multiple times a second. I don't know why the boot method would be getting called that frequently, but I have been noticing recently that my log file is too big to view.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Show price when item selected.
FilamentFFilament / ❓┊help
3y ago
How to render admin panel navigation item only for selected users
FilamentFFilament / ❓┊help
5mo ago
createOptionForm - item not automatically selected
FilamentFFilament / ❓┊help
2y ago