saade / filament-adjacency-list

A Filament package to manage adjacency lists (aka trees).
https://filamentphp.com/plugins/saade-adjacency-list
MIT License
74 stars 13 forks source link

[Bug]: Actions are not configurable #29

Open CodeWithDennis opened 4 months ago

CodeWithDennis commented 4 months ago

What happened?

Actions are not configurable

How to reproduce the bug

When trying to configure actions, such as the edit action, it doesn't seem to work.

For example, using:

AdjacencyList::make('descendants')
    ->label('Subcategories')
    ->editAction(fn(Action $action) => $action->slideOver())
    ->labelKey('name')
    ->relationship('descendants')
    ->form([
        Forms\Components\TextInput::make('name')
            ->required(),
    ]),

Doesn't seem to apply the slideOver() method correctly. However, if you manually add slideOver() to the action in the source code, it works, indicating that something is off with how the configurations are passed through. This issue occurs for all actions.

Here's the relevant source code:

public function getEditAction(): Actions\Action
{
    $action = Actions\EditAction::make()->slideOver(); // Testing here works
    if ($this->modifyEditActionUsing) {
        $action = $this->evaluate($this->modifyEditActionUsing, [
            'action' => $action,
        ]) ?? $action;
    }
    return $action;
}

It seems the configuration isn't being applied as expected when using the method to modify the edit action.

Package Version

v1.22

PHP Version

v8.3.4

Laravel Version

v11.9.2

Which operating systems does with happen with?

macOS

Notes

No response