React to Repeater being deleted
Is there a way to react to a repeater item being deleted?
I created a custom entry following the documentation here - https://filamentphp.com/docs/4.x/infolists/custom-entries
I have the following logic
Here is my function
calculatePaidAmount
In the first picture everything is being calculated correctly.
In the second image I'm entering an amount and the totals are being calcualted correctly.
In the last image, I have deleted the repeater item but the amounts didn't trigger an update so they didn't et recalculated.
So I need to figure out how to add reactivity to the repeater
being delete so I can recalculate paid amount or maybe my custon infolist component needs reactivity?


Solution:Jump to solution
This one work. To me also makes sense that
->delete
would trigger afterStateUpdated()
....4 Replies
There is no event, but you could overwrite the
DeleteAction
with one that fires an event via modifyDeleteActionUsing()
Something like this:
Deleting and item should call afterStateUpdated()
though. Not sure why it's not working. Maybe try ->partiallyRenderAfterUpdate('payment_summary')
Solution
This one work. To me also makes sense that
->delete
would trigger afterStateUpdated()
.
I got it working tho, thank you for the answerSo the solution is clashing with the reactivity inside the repeater....
If I add
->partiallyRenderComponentsAfterStateUpdated(['payment_summary'])
the payment_summary
updates correctly but the reactivity inside the schema stops working so the Grid stops generating fields. If I remove the partiallyRenderComponentsAfterStateUpdated
reactive inside repeater starts working but the payment_summary
doesn't update 😥
Already tried
Also, moved the logic to the blade file but everytime the repeater entry gets deleted it doesn't update
On the second update I commented
and the select change reacts correctly, the summary gets udpated correctly. However, deleting the repeater entry does nothing 🙁