How to close an ActionGroup dropdown with a custom action function

Is it possible to close the dropdown generated by an ActionGroup, when a custom function is called? Currently the dropdown will stay open after clicking on the action. I'm sure I'm missing something simple. Sample ViewRecord page below.
class ViewPost extends ViewRecord
{
protected static string $resource = PostResource::class;

protected function getActions(): array
{
return [
Actions\ActionGroup::make([
Actions\Action::make('publish-post')
->label('Publish blog post')
->action('publishPost'),
// other items ...
]),
];
}

public function publishPost()
{
$this->record->publish();

// hide the dropdown
}
}
class ViewPost extends ViewRecord
{
protected static string $resource = PostResource::class;

protected function getActions(): array
{
return [
Actions\ActionGroup::make([
Actions\Action::make('publish-post')
->label('Publish blog post')
->action('publishPost'),
// other items ...
]),
];
}

public function publishPost()
{
$this->record->publish();

// hide the dropdown
}
}
Any help is much appreciated!
2 Replies
LeandroFerreira
->action(fn () => $this->record->publish())
->extraAttributes(['x-on:click' => 'close'])
// or ->requiresConfirmation()
->action(fn () => $this->record->publish())
->extraAttributes(['x-on:click' => 'close'])
// or ->requiresConfirmation()
edwardwestbury
edwardwestburyOP2y ago
That was it, thanks so much!
Want results from more Discord servers?
Add your server