Hydrat-Agency / filament-table-layout-toggle

Filament plugin providing a toggle button for tables, allowing users to switch between Grid and Table layout.
MIT License
37 stars 6 forks source link

[Bug]: Header bar containing search and toggle button disappear #10

Open gmed2b opened 3 weeks ago

gmed2b commented 3 weeks ago

What happened?

I just found this plugin and wanted to give it a try. I'm in a standalone configuration, I mainly use Filament with Livewire as standalone (outside panels).

So, I've installed the package following Installation guide, published the configuration file as mentioned and configured the table.

public function getListTableColumns(): array
{
    return [...];
}

public function getGridTableColumns(): array
{
    return [
        Stack::make([
            Split::make([
                TextColumn::make('productVersion.name')
                    ->description(__('Product'), position: 'above'),
                TextColumn::make('productVersion.reference')
                    ->description(__('Reference'), position: 'above'),
            ])
        ])
    ];
}

public function table(Table $table): Table
{
  return $table
    ->query(...)
    ->actions([...])
    ->bulkActions([...])
    ->headerActions([...])
    ->columns(
        $this->isGridLayout()
        ? $this->getGridTableColumns()
        : $this->getListTableColumns()
    ->contentGrid(
        fn () => $this->isListLayout()
        ? null
        : [
            'md' => 2,
            '1g' => 3,
            'xl' => 4,
        ]
    );
}
Screenshot 2024-08-25 at 10 00 18

At this stage, everything went good, but as soon as I toggle the grid layout, the header bar containing the button and search input disappear :/

Screenshot 2024-08-25 at 10 00 26

How to reproduce the bug

Install the package and follow standalone configuration.

composer require hydrat/filament-table-layout-toggle

php artisan vendor:publish --tag="table-layout-toggle-config"

Add the HasToggleableTable trait to a Livewire component.

Package Version

2.0.0

PHP Version

8.3

Laravel Version

11.19.0

Which operating systems does with happen with?

macOS

Notes

Developping using Laravel Herd.

gmed2b commented 3 weeks ago

Update : I've found out that if we add a column with either searchable() or toggleable methods, it trigger the search input to be visible and also the layout.

if their is no methods that as a corresponding button in that area the layout button do not appear.

Hope that help !

tgeorgel commented 3 weeks ago

Hi @gmed2b

So by adding ->searchable() to one of your Grid Layout column it makes the bar appearing again in grid mode, right ?

Thanks for reporting this, I'll have a look to force the bar to trigger display when the table contains a toggle.

Cheers!

gmed2b commented 3 weeks ago

Hi @gmed2b

So by adding ->searchable() to one of your Grid Layout column it makes the bar appearing again in grid mode, right ?

Thanks for reporting this, I'll have a look to force the bar to trigger display when the table contains a toggle.

Cheers!

Hi, yes exactly, the toggle is not visible by itself.

tgeorgel commented 3 weeks ago

Thanks @gmed2b, happy it works for you now! Will try to make this appears by default.

gmed2b commented 3 weeks ago

@tgeorgel Thank you, I also have another suggestion, idk if i need to open antoher issue, but i've installed this package to add responsiveness in my app, it would be great if their were a way to auto toggle between list or grid depending on a breakpoint.

I've search and found the changeLayoutView method, i've been trying to listen to resize window with alpine and livewire but i'm struggling :/ Do you have any idea how to achieve this ?

Thank you

tgeorgel commented 3 weeks ago

I made this plugin specifically for responsiveness, so I would say the idea is good.

I actually don't know if we can capture the width size of the window with alpine in order to trigger the toggle event : I'll have a look.

gmed2b commented 3 weeks ago

All right, thank. I'll check aswell