Refresh a modal after an extra footer action is performed?

Hi there! I have a question regarding this part of the docs: https://filamentphp.com/docs/3.x/actions/modals#adding-an-extra-modal-action-button-to-the-footer I have a Table displaying invoices. Each row provides a ViewAction to open a modal to view the invoice details. An Invoice may have a state (Open, Booked, Checked, Paid, etc.) and the modal should provide a n extra footer action depending on the current state to move the invoice to it's next state. For example, if the invoice is "open", I want to have the "book" action in my modal footer. Here is the relevant bit of my code:
public function table(Table $table): Table
{
return $table
->actions([
Tables\Actions\ViewAction::make()
->modalWidth(MaxWidth::SevenExtraLarge)
->modalContent(fn (Invoice $record) => view('filament.project.pages.invoice', ['invoice' => $record]))
->extraModalFooterActions(fn (Invoice $record): array => $this->getNextInvoiceActions($record->status))
]);
}
public function table(Table $table): Table
{
return $table
->actions([
Tables\Actions\ViewAction::make()
->modalWidth(MaxWidth::SevenExtraLarge)
->modalContent(fn (Invoice $record) => view('filament.project.pages.invoice', ['invoice' => $record]))
->extraModalFooterActions(fn (Invoice $record): array => $this->getNextInvoiceActions($record->status))
]);
}
Now my problem is this: after performing the action that is returned from getNextInvoiceActions() I need the modal to refresh. So if we move from "open" to "booked", I now need the "check" action in my footer. However, I still have the "book" action in my footer, which then results in a weird state situation. I can solve this issue by adding ->cancelParentActions() to my action definitions in getNextInvoiceActions() . However, this will close the view modal, after completing the action, requiring the user to look for the invoice in the table again and reopening the view modal to proceed with other actions, which is not a good UX. Is there to somehow "refresh" the parent of an extra action after it is performed?
1 Reply
Samus_Aran
Samus_Aran2mo ago
Nevermind, I think I got the solution. I had to define all actions at once within extraModalFooterActions() and then for each action define the display behaviour as a closure. for example with my "check" action: ->visible(fn (Invoice $record) => $record->status === InvoiceStatus::Booked) This will cause the desired refresh behaviour of my modal footer.