filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
19.58k stars 2.98k forks source link

Reorder button always hidden when using tabs #14371

Open IlliaVeremiev opened 2 months ago

IlliaVeremiev commented 2 months ago

Package

filament/filament

Package Version

v3.2.106

Laravel Version

v11.21.0

Livewire Version

v3.5.6

PHP Version

PHP 8.2.12

Problem description

Have Filament Resource with ListRecords page. On ListRecords page, getTabs method is implemented (With All and Some tabs) Table defined as reorderable with condition, that All tab is not reorderable.

class MenuItemResource extends Resource
{
    // $model, $navigationIcon, ...

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('name')->required(),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('name'),
            ])
            ->reorderable('order', fn (Page $livewire) => $livewire->activeTab !== 'all');
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListMenuItems::route('/'),
        ];
    }
}

class ListMenuItems extends ListRecords
{
    protected static string $resource = MenuItemResource::class;

    public function getTabs(): array
    {
        return [
            'all' => Tab::make(),
            'some' => Tab::make(),
        ];
    }
}

When open dashboard and navigate to resource page, reorder button is hidden, when navigate Some tab, it is still hidden. If refresh the page on Some tab, it works as expected. The problem happens only if navigated to the Resource page from another page (Dashboard or other Resources).

Expected behavior

When navigate All tab, reorder button should be hidden. When navigate Some tab, reorder button should be displayed

Steps to reproduce

  1. Navigate Dashboard page
  2. Navigate Resource page with several tabs and reorderable condition to be hidden on the first tab
  3. Navigate tab where reorderable should be displayed

This seems to be happening because the header toolbar container has the display: none style. Even though the button tends to be rendered.

As a temporary workaround I created custom action button, that calls toggleTableReordering

Reproduction repository (issue will be closed if this is not valid)

https://github.com/IlliaVeremiev/filament-reorderable-with-tabs-issue

Relevant log output

No response

Donate 💰 to fund this issue

Fund with Polar

leandrocfe commented 2 months ago

I believe the issue occurs because the table header is hidden when the page initially loads, as there are no items to display. A simple solution would be to make one of the table columns searchable which would force the table header/toolbar to appear:

TextColumn::make('name')
    ->searchable()
IlliaVeremiev commented 2 months ago

@leandrocfe, it works! Thanks!