© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
Andrew Wallo

How to Reset the Active Tab in Table

So, I am displaying tabs dynamically, and it works, but when a User deletes all of the records that are "connected", even though all of the tabs disappear correctly and the default table from
index
index
view is shown, the "connected" active tab query string in the URL is still shown. Setting it to null doesn't work and instead just makes the query string in the URL actually be
?activeTab=null
?activeTab=null
. Which seems odd.

The only way I could get it to work correctly is by redirecting to the index view URL. Is there a simpler way?

public function getTabs(): array
{
    if (! Account::where('is_connected_account', true)->exists()) {
        if ($this->activeTab === 'connected') {
            $this->redirect(url(static::getUrl()));
        }

        return [];
    }

    return [
        'manual' => Tab::make('Manual')
            ->modifyQueryUsing(function (Builder $query) {
                $query->where('is_connected_account', false)
                    ->whereNull('available_balance');
            }),
        'connected' => Tab::make('Connected')
            ->modifyQueryUsing(function (Builder $query) {
                $query->where('is_connected_account', true)
                    ->whereNotNull('available_balance');
            }),
    ];
}
public function getTabs(): array
{
    if (! Account::where('is_connected_account', true)->exists()) {
        if ($this->activeTab === 'connected') {
            $this->redirect(url(static::getUrl()));
        }

        return [];
    }

    return [
        'manual' => Tab::make('Manual')
            ->modifyQueryUsing(function (Builder $query) {
                $query->where('is_connected_account', false)
                    ->whereNull('available_balance');
            }),
        'connected' => Tab::make('Connected')
            ->modifyQueryUsing(function (Builder $query) {
                $query->where('is_connected_account', true)
                    ->whereNotNull('available_balance');
            }),
    ];
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to get active tab when using table tab filters?
FilamentFFilament / ❓┊help
3mo ago
How to get active tab in beforeValidation()
FilamentFFilament / ❓┊help
2y ago
How to hide/show table column based on the active tab?
FilamentFFilament / ❓┊help
2y ago
Get the active tab
FilamentFFilament / ❓┊help
3y ago