Tricks

Close an action group dropdown after click

Apr 14, 2023
Martin Mildner
Table builder

Have you ever struggled with closing an action group dropdown after choosing an action?

I've stumbled upon a neat solution by using extraAttributes(). Check out the code snippet below:

ActionGroup::make([
Action::make('publish')
->action(fn (Post $record) => $record->publish())
->extraAttributes(['x-on:click' => 'toggle']),
 
Action::make('delete')
->action(fn (Post $record) => $record->delete())
->extraAttributes(['x-on:click' => 'toggle']),
])

No comments yet…