-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Package
filament/filament
Package Version
v4.0.4
Laravel Version
v12.26.3
Livewire Version
v3.6.4
PHP Version
PHP 8.3.0
Problem description
When a suffix action is provided to an infolist entry as a callback it fails to update when the relationship updates from the same entry.
The callback in question:
->suffixAction(function (User $user) {
$documents = $user->documents->count();
return Action::make('download')
->requiresConfirmation()
->badge()
->label($documents)
->action(function () {
Notification::make()
->title('Downloading')
->send();
});
})
Removing it from the callback, it updates just fine.
->suffixAction(
Action::make('download')
->requiresConfirmation()
->badge()
->label(fn(User $user) => $user->documents->count())
->action(function () {
Notification::make()
->title('Downloading')
->send();
})
),
Expected behavior
I would expect the callback passed to the suffixAction
method to update and receive an updated collection when a relationship is updated from an action on the same entry.
This is needed when you want to render two different versions of a suffix action depending on relationship collection (e.g. download single vs download in modal).
Steps to reproduce
-
Clone rep, migrate & run seeder.
-
Login with
[email protected]
&password
. -
Navigate to /admin/user/1.
-
Use the upload action on the left 'Works' entry and see that the suffix action on the other entry updates as normal.
-
Use the upload action on the right
Does not work
entry and see that the suffix action on the same entry does not update, even though the state updates as expected.
Reproduction repository (issue will be closed if this is not valid)
https://github.com/harvey-4thd/filament-relation-cached-in-suffix-action-callback
Relevant log output
Metadata
Metadata
Assignees
Labels
Type
Projects
Status