How to refresh the tab component of a relation manager?
I use this example from the docs: https://filamentphp.com/docs/4.x/resources/managing-relationships#customizing-relation-manager-tabs
When I create a new record or delete an existing one the badge count does not refresh. I tried to use a closure inside the badge() method and
$this->dispatch('$refresh');
inside my action methods but it didn't solve the problem.Solution:Jump to solution
GitHub
Tab badge count not updating for relationships after creating a new...
Package Other Package Version ^4.0 How can we help you? Tab badge count not updating for relationships after creating a new resource in a modal. Tried to dispatch an event, but that also does not w...
19 Replies
@larsbo
You can do something like this:
https://filamentphp.com/docs/4.x/actions/delete#lifecycle-hooks
You only have to find where to put the
#[On('event-name')]
part. I do not use the getTabComponent()
method, but if you do maybe try to put it on that method.@TDDeveloper Tried it on
getTabComponent()
but no luck.I will try to look at it later
Thank you! I already searched the code for some entry point, but no idea so far π
@TDDeveloper Did you find out someting about this?
@larsbo
I did not have the time yet to look at it. Will check it today
In your EditPage
Still no update π I tryed both with DeleteAction and DeleteBulkAction.
A
dd()
inside the the after() method works, but a dd()
inside the refreshPage() method was not executed.where did you add the refreshPage method?
First inside my EditPage. Now I put it inside the RelationManager class and now it was triggered when I test it with dd().
#[On('refreshPage')]
public function refreshPage(): void {
dd('test');
}
but without dd() nothing happens
This works on my end. Please create a minimal repo on github to reproduce this issue and I can take a look
it updates the tab count of the relationship or the one in the main navigation bar?
Because I can't get it to work either, only updates on the main navigation work
it updates the page, so I think it should update all
I will try to make a project this evening
I just created a minimal example. And I can confirm calling
dispatch('refreshPage')
in the after()
method of the create or delete action refreshes the tab counter... π π
That means the issue is somewhere else πDo you use modals in your non-test application?
This is where it goes wrong in my example application
https://github.com/Merdin/filament-badgecount-bug
@TDDeveloper yes, I do. Without modal there is a full page refresh after creation, isn't it?
btw: we build almost the same minimal example with posts and comments π
here is my repo with the refresh solution: https://github.com/kielcoding/filament-issue
GitHub
GitHub - kielcoding/filament-issue
Contribute to kielcoding/filament-issue development by creating an account on GitHub.
Solution
GitHub
Tab badge count not updating for relationships after creating a new...
Package Other Package Version ^4.0 How can we help you? Tab badge count not updating for relationships after creating a new resource in a modal. Tried to dispatch an event, but that also does not w...