F
Filament8mo ago
Ron

How to close an ActionGroup dropdown with a custom function after the function completes

I see from a similar post how to close the drop down immediately on click, but is there a way to close the drop down within the custom function itself to preserve the progress spinner on the action? The code below shows an action w/in a group where the drop down is closed immediately (this code was from a similar post)
ActionGroup::make([
Action::make('process')
->action(function (Action $action) {
// ... run process function
// Is it possible to use the injected Action to close here, after processing
})
// Adding Extra Attributes will close the drop down immediately
->extraAttributes(['x-on:click' => 'close']),
])->button();
ActionGroup::make([
Action::make('process')
->action(function (Action $action) {
// ... run process function
// Is it possible to use the injected Action to close here, after processing
})
// Adding Extra Attributes will close the drop down immediately
->extraAttributes(['x-on:click' => 'close']),
])->button();
Solution:
Its a bit similar: Here is an example code: ```php...
Jump to solution
2 Replies
Solution
Majid Al Zariey
Majid Al Zariey8mo ago
Its a bit similar: Here is an example code:
ActionGroup::make([
Action::make('test')
->action(fn() => $v = "do something")
->after(fn($livewire)=>
$livewire->dispatch('close-menu')),
])->extraAttributes([
"x-on:close-menu.window" => <<<JS
close();
JS
])
ActionGroup::make([
Action::make('test')
->action(fn() => $v = "do something")
->after(fn($livewire)=>
$livewire->dispatch('close-menu')),
])->extraAttributes([
"x-on:close-menu.window" => <<<JS
close();
JS
])
Ron
RonOP8mo ago
@Majid Al Zariey thank you for the quick response and the solution. That code worked perfectly.

Did you find this page helpful?