How to Disable Table Polling in a Header Action on a Resource List Page?
I'm working with Filament and trying to disable polling for a resource table when a header action is triggered. However, my approach doesn't seem to work.
Here’s my setup:
In
In
However, this doesn't seem to stop the polling when the action is executed.
Is there a correct way to dynamically disable table polling within an action? Would appreciate any insights!
Here’s my setup:
In
MyResource
, I define the table with polling enabled:In
MyResourceListPage
, I try to disable polling within a header action:However, this doesn't seem to stop the polling when the action is executed.
Is there a correct way to dynamically disable table polling within an action? Would appreciate any insights!
5 Replies
Your approach would work for current requests only. The change is not persisted anywhere.
Try writing it to a property
$pollingEnabled
and use ->poll(fn ($livewire) => $livewire->pollingEnabled ? '5s' : null)
OK, I made the change, but it still doesn't work.
I updated my table configuration as follows:
And in my header action:
However, the polling is still running. Any idea why this isn't working?
I updated my table configuration as follows:
And in my header action:
However, the polling is still running. Any idea why this isn't working?
Maybe that part is just not refreshed. You could try to reload the whole page after that change.
Btw. why do you use
->mountUsing()
and not ->action()
?My reason for using
But I am indeed using an
I managed to make it work in a very improvised way.
The issue is that I have a header action that opens a form, which in turn has a creation option.
Due to polling, I was having problems when trying to submit the open modals because the actions were being disabled between polling intervals.
Another issue was that when filling in some file upload fields, the files would disappear if a polling event occurred while they were still being uploaded.
I searched in various places before coming here and checked this article:
Understanding Laravel Filament V3: Resolving Disabled Action Components on ViewResource with Polling,
but I couldn't find a way to stop the polling when opening the modal and resume it when closing (whether the action was submitted or not).
The way I managed to solve it was by combining your suggestion with the following code:
It was improvised, but I managed to enable and disable polling only when the first modal in the chain is opened or closed (regardless of whether the action was submitted or not). If you have a better suggestion, I'd love to hear it!
mountUsing
was to stop the polling after the action was mounted.But I am indeed using an
->action()
.I managed to make it work in a very improvised way.
The issue is that I have a header action that opens a form, which in turn has a creation option.
Due to polling, I was having problems when trying to submit the open modals because the actions were being disabled between polling intervals.
Another issue was that when filling in some file upload fields, the files would disappear if a polling event occurred while they were still being uploaded.
I searched in various places before coming here and checked this article:
Understanding Laravel Filament V3: Resolving Disabled Action Components on ViewResource with Polling,
but I couldn't find a way to stop the polling when opening the modal and resume it when closing (whether the action was submitted or not).
The way I managed to solve it was by combining your suggestion with the following code:
It was improvised, but I managed to enable and disable polling only when the first modal in the chain is opened or closed (regardless of whether the action was submitted or not). If you have a better suggestion, I'd love to hear it!