FilamentF
Filament3y ago
WrkL

How to properly hide / show headerAction dynamically ?

as shown in the video, the header action should be hidden on mount but it didnt and it also render three dots menu when the button is hidden.
it work as intended when i replace the hidden method to be extraAttribute ( alpine x-show )
below is the code :

class Testing extends Component implements HasTable
{
    use InteractsWithTable;

    public $showHeaderActionsButton = false;

    protected function getTableQuery(): Builder|Relation
    {
        return PromoHeader::query();
    }

    protected function getTableHeaderActions(): array
    {
        return [
            Action::make('testing')
                ->label('Test')
                ->button()
                ->action(fn () => dd('hello'))
                // ->extraAttributes([
                //     'x-show' => '! $wire.showHeaderActionsButton'
                // ])
                ->hidden($this->showHeaderActionsButton)
        ];
    }

    protected function getTableColumns(): array
    {
        return [
            TextColumn::make('id'),
            TextColumn::make('updated_at'),
        ];
    }
}
Was this page helpful?