2nd action click produces empty modal

I have several Page classes where I'm using actions. I've noticed that if I click one action, then click another one, an empty modal will pop up (See screenshot). Here's an example:
protected function getActions(): array
{
return [
Action::make('Export to Excel')
->label('Export to Excel')
->icon('heroicon-o-document-arrow-down')
->action(function () {
return $this->exportToExcel();
}),
Action::make('Export to PDF')
->label('Export to PDF')
->icon('heroicon-o-document-arrow-down')
->action(function () {
return $this->saveAsPdf();
}),
];
}
protected function getActions(): array
{
return [
Action::make('Export to Excel')
->label('Export to Excel')
->icon('heroicon-o-document-arrow-down')
->action(function () {
return $this->exportToExcel();
}),
Action::make('Export to PDF')
->label('Export to PDF')
->icon('heroicon-o-document-arrow-down')
->action(function () {
return $this->saveAsPdf();
}),
];
}
if I load up the page and click the Export to Excel action, it works fine, but if I were to click the export to PDF action first, and then click export to excel without refreshing the page, it opens the modal. I've noticed this across a few different pages/actions and I'm not sure what I'm doing wrong.
No description
5 Replies
awcodes
awcodes3mo ago
Not sure if it will solve your issue or not, but the name of the action should be treated as a slug/identifier, maybe the spaces are throwing it off.
Action::make('export_to_excel')
Action::make('export_to_pdf')
Action::make('export_to_excel')
Action::make('export_to_pdf')
Jon Mason
Jon Mason3mo ago
oh that's a good point, I didn't even notice that. I'll try it out. this didn't work, I've tried removing the calls to the other methods just to try and test the action itself and it's still happening. Maybe someone has run into this before and knows how to fix it..
awcodes
awcodes3mo ago
it's going to be something in your action. could be the return or could even be something specific you are doing the methods.
awcodes
awcodes3mo ago
use Filament\Actions\Action;

protected function getHeaderActions(): array
{
return [
Action::make('export_to_excel')
->label('Export to Excel')
->icon('heroicon-o-document-arrow-down')
->action(function () {
dd('excel export');
}),
Action::make('export_to_pdf')
->label('Export to PDF')
->icon('heroicon-o-document-arrow-down')
->action(function () {
dd('pdf export');
}),
];
}
use Filament\Actions\Action;

protected function getHeaderActions(): array
{
return [
Action::make('export_to_excel')
->label('Export to Excel')
->icon('heroicon-o-document-arrow-down')
->action(function () {
dd('excel export');
}),
Action::make('export_to_pdf')
->label('Export to PDF')
->icon('heroicon-o-document-arrow-down')
->action(function () {
dd('pdf export');
}),
];
}
Jon Mason
Jon Mason3mo ago
ok, that's good to know, thanks for the insights. I'll go back to my action methods and make sure nothing weird is going on there.
Want results from more Discord servers?
Add your server
More Posts