F
Filamentβ€’13mo ago
Chriis

Get the active tab

Hi, how can I get the active tab of my Resource table ?
11 Replies
Tieme
Tiemeβ€’13mo ago
Please see https://discord.com/channels/883083792112300104/1167015843020943390 Section, how to write good question. Because what are you doing, what is the code?
Chriis
ChriisOPβ€’13mo ago
I really need to explain whats a table Tab ? πŸ˜‘
Jordy
Jordyβ€’13mo ago
I think they use it in the demo and persist it to the url source code is on github
Chriis
ChriisOPβ€’13mo ago
Yes its in the URL by default but I try to find a method like getActiveTab() or something like that for doing condition on my Resource Like for example, hidding the delete bulkaction when in the 'archived' tab
Jordy
Jordyβ€’13mo ago
hm put it in the session when the getTabs method is called and base your visbility on that? just a thought.. not sure if possible
Chriis
ChriisOPβ€’13mo ago
Hmmn, not sure to understand 😬
Jordy
Jordyβ€’13mo ago
so for the tabs, you define a query https://github.com/filamentphp/demo/blob/678ef5c53f219a2032c0ae70fd5b5e7d3cfeb9b5/app/Filament/Resources/Shop/OrderResource/Pages/ListOrders.php#L31 not sure if you can make it a callback and make it it also persists what tab is active in the session then you could create your getActiveTab function yourself and base the visbility of your bulkaction on it and worth trying the default https://www.php.net/manual/en/reserved.variables.get.php
$_GET['activeTab']
$_GET['activeTab']
Chriis
ChriisOPβ€’13mo ago
$_GET['activeTab'] don't work sadly 😦
Sanchit Patil
Sanchit Patilβ€’13mo ago
something like this?
Tables\Actions\EditAction::make()->hidden(function (){
return ((request()->query('activeTab') === 'archived'));
}),
Tables\Actions\EditAction::make()->hidden(function (){
return ((request()->query('activeTab') === 'archived'));
}),
Chriis
ChriisOPβ€’13mo ago
After some little modification for my need it worked πŸ™‚ Thanks for your help And I found a bug with tabs and bulkActions πŸ‘€ When you switch between actions the selection state is not cleared and its mess with the bulk actions you see even on the right tab ^^
Sanchit Patil
Sanchit Patilβ€’13mo ago
Oh yes, sorry my bad. not sure how to update this between the states if we do something like this on the ListRecords page
public string $activetab = 'none';
public function mount(): void
{
$this->activetab = request()->query('activeTab');
}
public string $activetab = 'none';
public function mount(): void
{
$this->activetab = request()->query('activeTab');
}
not sure how to access activetab in the Resource class.
Want results from more Discord servers?
Add your server