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.03k stars 2.94k forks source link

getTableReorderColumn let headerActions dissapear inside a relationManager #3265

Closed annejan89 closed 2 years ago

annejan89 commented 2 years ago

Package

filament/filament

Package Version

v2.15.2

Laravel Version

v9.22.0

Livewire Version

v2.10.6

PHP Version

v8.1.3

Problem description

Using method below to sort table rows by given column.

  protected function getTableReorderColumn(): ?string
    {
        return 'sort';
    }

When using this inside a relationManager the CreateAction button in the header disappears.

->headerActions([
                Tables\Actions\CreateAction::make(),
])

Expected behavior

Without using the getTableReorderColumn() method the create button shows correctly.

->headerActions([
                Tables\Actions\CreateAction::make(),
])

Steps to reproduce

Tried to overwrite the canCreate method inside the Relationmanager, but without any luck. Guess that getTableReorderColumn doesn't respect and merge with existing headerActions.

Reproduction repository

No response

Relevant log output

No response

zepfietje commented 2 years ago

@annejan89, does the button disappear while reordering only, or permanently?

Also, could you share the exact code you use to configure the reordering on the relation manager? Usually, you'd just chain reorderable('sort') on the table inside the table() method on the relation manager class.

If you could set up a repository which reproduces the problem, we're able to fix the issue much faster.

annejan89 commented 2 years ago

@annejan89, does the button disappear while reordering only, or permanently?

Permanently

When reordering is turned off / default:

Schermafbeelding 2022-07-27 om 18 47 50

While reordering:

Schermafbeelding 2022-07-27 om 18 47 05

After deleting the getTableReorderColumn() method:

Schermafbeelding 2022-07-27 om 18 49 24
zepfietje commented 2 years ago

@annejan89 how exactly are you configuring the reordering functionality? 👇

Also, could you share the exact code you use to configure the reordering on the relation manager? Usually, you'd just chain reorderable('sort') on the table inside the table() method on the relation manager class.

If you could set up a repository which reproduces the problem, we're able to fix the issue much faster.

annejan89 commented 2 years ago

Tried both ways, both cause the problem as described:

class ShiftsRelationManager extends RelationManager { ....

    protected function getTableReorderColumn(): ?string
    {
        return 'sort';
    }

Using reorderable() within the table method:

 public static function table(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('name')->label('Naam'),
                BadgeColumn::make('status_badge')->label('Capaciteit')

            ])
            ->filters([
                //
            ])
            ->headerActions([
                Tables\Actions\CreateAction::make(),
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
                Tables\Actions\DeleteAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
            ])
            ->reorderable('sort');
    }
zepfietje commented 2 years ago

Thanks for the more detailed snippets, @annejan89.

I can't reproduce the problem. Header actions show just fine for me when configuring a table as reorderable. Could you set up a clean Laravel project with minimal code required to show the problem? If you share the repository URL here, we can have a look.

martinmildner commented 2 years ago

The same thing happens to me. As soon as I add protected function getTableReorderColumn() to the Relation Manager, the headerAction disappears Screenshot-2022-07-28 at 11 19 06@2x

Adding

protected function getTableReorderColumn(): ?string
{
    return 'sort';
}

results in

Screenshot-2022-07-28 at 11 10 41@2x

.

zepfietje commented 2 years ago

I still can't reproduce the issue. As I asked before, could someone set up a reproduction repository?

danharrin commented 2 years ago

Are you all on the latest version? I think I fixed this 2 days ago in v2.15.3, the issue report is v2.15.2

martinmildner commented 2 years ago

thxxx, @danharrin! it's fixed in v2.15.3