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

Action Rules is being applied to all buttons #1166

Closed
hitaloramon opened this issue Sep 22, 2023 · 2 comments
Closed

Action Rules is being applied to all buttons #1166

hitaloramon opened this issue Sep 22, 2023 · 2 comments

Comments

@hitaloramon
Copy link

Have you searched through other issues to see if your problem is already reported or has been fixed?

Yes, I did not find it.

Did you read the documentation?

Yes, I did not find it.

Have you tried to publish the views?

Yes - I didn't work.

Is there an error in the console?

No

PHP Version

8.2.9

PowerGrid

5.1.0

Laravel

10.24.0

Livewire

3.0.5

Alpine JS

No response

Theme

Tailwind 3.x

Describe the bug.

When I have more than one button and I have rules for them, the rules are being applied to all buttons

image

To Reproduce...

public function actions(Dish $dish): array
    {
        return [
            Button::add('edit')
                ->slot('edit'),
            
                Button::add('destroy')
                ->slot('Destroy'),
        ];
    }

    public function actionRules(): array
    {
        return [
            Rule::button('edit')
                ->when(fn ($dish) => $dish->id == 2)
                ->setAttribute('class', 'bg-green-200'),

            Rule::button('destroy')
                ->when(fn ($dish) => $dish->id == 2)
                ->slot('Delete #1'),
        ];
    }

Extra information

No response

@luanfreitasdev
Copy link
Collaborator

Thanks for looking into this issue! A bug fix is coming up.

@luanfreitasdev
Copy link
Collaborator

Fixed

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

No branches or pull requests

2 participants