Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extra item actions #104

Merged
merged 3 commits into from
Feb 22, 2024
Merged

Conversation

sandersjj
Copy link
Contributor

@sandersjj sandersjj commented Feb 18, 2024

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

edit_order.mp4

@awcodes awcodes merged commit 1b185a5 into awcodes:3.x Feb 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants