F
Filament13mo ago
Matthew

Unexpected behavior of deleteAction() in Widget

Well, I have a button in a widget, and I want to make its visibility conditional, to the users permissions
public function deleteAction(): Action
{
return Action::make('delete')
->label('')
->tooltip(!auth()->user()->can('delete_comments::report') ? 'You dont have access to delete' : 'Delete comment')
->hidden(!auth()->user()->can('delete_comments::report'))
->requiresConfirmation()
->modalHeading('Delete comment')
->modalDescription('Are you sure you\'d like to delete this post? This cannot be undone.')
->modalSubmitActionLabel('Yes, delete it')
->color('danger')
->icon('heroicon-m-trash')
->size('sm')
->action(function (array $arguments) {
$comment = Comment::find($arguments['id']);
$comment?->delete();
Notification::make()
->title('Deleted successfully')
->success()
->send();
$this->dispatch('placeComment'); // Refresh the page
});
}
public function deleteAction(): Action
{
return Action::make('delete')
->label('')
->tooltip(!auth()->user()->can('delete_comments::report') ? 'You dont have access to delete' : 'Delete comment')
->hidden(!auth()->user()->can('delete_comments::report'))
->requiresConfirmation()
->modalHeading('Delete comment')
->modalDescription('Are you sure you\'d like to delete this post? This cannot be undone.')
->modalSubmitActionLabel('Yes, delete it')
->color('danger')
->icon('heroicon-m-trash')
->size('sm')
->action(function (array $arguments) {
$comment = Comment::find($arguments['id']);
$comment?->delete();
Notification::make()
->title('Deleted successfully')
->success()
->send();
$this->dispatch('placeComment'); // Refresh the page
});
}
But for some reason, whether I make it visible(false) or hidden(true), it shows up disabled The tooltip doesnt even work
No description
1 Reply
Matthew
MatthewOP13mo ago
Can anyone pls help?
Want results from more Discord servers?
Add your server