Laravel Filament V3 causes Action components on ViewResource to be disabled on polling

As the title suggests I have an application that receives a huge amount of data that gets updated aproximately 3-5 times every second for each record in the database. It is required that my application displays the data live using polling.

I’m using laravel filament v3 and a FilamentResourcesPagesViewRecord class to display the detail of my resource.

I’m using its infolist() method to display my resource columns via TextEntry class instance as such:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>FilamentInfolistsComponentsTextEntry::make('updated_at')
->extraAttributes(['wire:poll.1s' => '']),
</code>
<code>FilamentInfolistsComponentsTextEntry::make('updated_at') ->extraAttributes(['wire:poll.1s' => '']), </code>
FilamentInfolistsComponentsTextEntry::make('updated_at')
    ->extraAttributes(['wire:poll.1s' => '']),

This works well and using the extraAttributes() chain method on even one of my TextEntry instances causes the entire resource detail to rerender all of its data correctly.

In the getActions() I have a set of actions such as this one:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Action::make('Test Action')
->requiresConfirmation()
->action(function () use ($model) {
... random action logic ...
}),
</code>
<code>Action::make('Test Action') ->requiresConfirmation() ->action(function () use ($model) { ... random action logic ... }), </code>
Action::make('Test Action')
    ->requiresConfirmation()
    ->action(function () use ($model) {
        ... random action logic ...
    }),

This action opens a modal that contains a submit button used for final action confirmation before submitting the form and causing the action logic to get executed.

Here’s whats currently causing me trouble:

When the action opens there is still the polling logic getting executed in the background. During the execution of the polling logic the submit button gets disabled for a short time. So since I’m polling my form every single second, my submit button also gets disabled for a short time and reenabled again.

I have tried going through the filament/actions/resources/views and filament/filament/resources/views/components blade templates and removing references of :disable or :isProcessing livewire attributes but nothing seems to work.

Also I have found no particular references to my specific use case in the laravel filament documentation (polling on resource detail view while also implementing actions) and ChatGPT is also lost.

What is the recommended way for implementing my specific use case in laravel filament v3?

How can I prevent the submit button from getting disabled during polling?

2

There is a bug currently introduced into filament v3 that causes the modal-close event to not get fired – see FilamentInfolistsConcernsInteractsWithInfolists.php and line 330:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>if ($shouldCloseModal) {
$this->dispatch('close-modal', id: "{$this->getId()}-infolist-action");
}
</code>
<code>if ($shouldCloseModal) { $this->dispatch('close-modal', id: "{$this->getId()}-infolist-action"); } </code>
if ($shouldCloseModal) {
    $this->dispatch('close-modal', id: "{$this->getId()}-infolist-action");
}

the $shouldCloseModal boolean gets passed in as false even on proper Action closing, causing the modal-close event to not get fired.

I have bypassed said problem by overloading the entire public function unmountInfolistAction(bool $shouldCancelParentActions = true, bool $shouldCloseModal = true): void method.

Then I also overloaded the public function dispatch($event, ...$params): void method from LivewireFeaturesSupportEventsHandlesEvents trait since the $listeners events also dont work.

This is the key snippet of code that then allowed me to control the polling on modal opening and closing events:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>class ViewEntity extends ViewRecord
{
public bool $isPolling = true;
public function dispatch($event, ...$params): void
{
if ($event === 'open-modal') {
$this->isPolling = false;
}
if ($event === 'close-modal') {
$this->isPolling = true;
}
parent::dispatch($event, ...$params);
}
}
</code>
<code>class ViewEntity extends ViewRecord { public bool $isPolling = true; public function dispatch($event, ...$params): void { if ($event === 'open-modal') { $this->isPolling = false; } if ($event === 'close-modal') { $this->isPolling = true; } parent::dispatch($event, ...$params); } } </code>
class ViewEntity extends ViewRecord
{
    public bool $isPolling = true;

    public function dispatch($event, ...$params): void
    {
        if ($event === 'open-modal') {
            $this->isPolling = false;
        }

        if ($event === 'close-modal') {
            $this->isPolling = true;
        }

        parent::dispatch($event, ...$params);
    }
}

Here is the overloading trait I’ve added to my ViewRecord class to fix the aformentioned bug:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><?php
declare(strict_types=1);
namespace AppFilamentTraits;
trait InfolistActionUnmountFixTrait
{
/**
* TODO: there is a bug currently introduced in the filament that causes the close-modal event to not get dispatched, this overload is a fix to said bug.
*
* @throws Exception
*/
public function unmountInfolistAction(bool $shouldCancelParentActions = true, bool $shouldCloseModal = true): void
{
parent::unmountInfolistAction($shouldCancelParentActions, $shouldCloseModal);
$this->dispatch('close-modal', id: "{$this->getId()}-infolist-action");
}
}
</code>
<code><?php declare(strict_types=1); namespace AppFilamentTraits; trait InfolistActionUnmountFixTrait { /** * TODO: there is a bug currently introduced in the filament that causes the close-modal event to not get dispatched, this overload is a fix to said bug. * * @throws Exception */ public function unmountInfolistAction(bool $shouldCancelParentActions = true, bool $shouldCloseModal = true): void { parent::unmountInfolistAction($shouldCancelParentActions, $shouldCloseModal); $this->dispatch('close-modal', id: "{$this->getId()}-infolist-action"); } } </code>
<?php

declare(strict_types=1);

namespace AppFilamentTraits;

trait InfolistActionUnmountFixTrait
{
    /**
     * TODO: there is a bug currently introduced in the filament that causes the close-modal event to not get dispatched, this overload is a fix to said bug.
     *
     * @throws Exception
     */
    public function unmountInfolistAction(bool $shouldCancelParentActions = true, bool $shouldCloseModal = true): void
    {
        parent::unmountInfolistAction($shouldCancelParentActions, $shouldCloseModal);

        $this->dispatch('close-modal', id: "{$this->getId()}-infolist-action");
    }
}

Very hacky, but the best thing that I have at the moment.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật