awcodes / filament-table-repeater

A modified version of the Filament Forms Repeater to display it as a table.
MIT License
201 stars 43 forks source link

Fix extra item actions #104

Closed sandersjj closed 7 months ago

sandersjj commented 7 months ago

Hey,

Not sure If I am doing something wrong or it is a bug. It's about the icon being visible or not (the hidden function) I have this code in my OrderResource:

->extraItemActions([
    Action::make('openProduct')
        ->tooltip('Open product')
        ->icon('heroicon-m-arrow-top-right-on-square')
        ->url(function (array $arguments, Repeater $component): ?string {
            $itemData = $component->getRawItemState($arguments['item']);

            $product = Product::find($itemData['product_id']);

            if (! $product) {
                return null;
            }

            return ProductResource::getUrl('edit', ['record' => $product]);
        }, shouldOpenInNewTab: true)
        ->hidden(function (array $arguments, Repeater $component): bool {
            return blank($component->getRawItemState($arguments['item'])['product_id']);

        })
])

When I add the first item to the repeater the hidden function returns true show it shows the link. However when adding the second item, the hidden function returns false. Now the expected behaviour is that by the first item you show still see the link but not by the second one. In my code both rows don't show the links. Not sure if this is a bug or not...

Here is a more visual representation of the issue

https://github.com/awcodes/filament-table-repeater/assets/176772/74437797-e55d-4a5e-b456-0763b52467aa