FilamentF
Filament7mo ago
Mombei

Table on livewire component is involuntarily refreshing component on Action

I have a filament Table in a livewire component, with a simple Action:
public function table(Table $table): Table {
        return $table
            ->query(/**/)
            ->columns([/**/])
            ->recordAction('myAction')
            ->recordUrl(null)
            ->actions([
                Action::make('myAction')
                    ->action(fn(Model $record) => 
                    /* Here I've tried a couple things */
                    $this->dispatch(new SomeEvent($record->id)))
                    /* or */
                    event(new SomeEvent($record->id))
            ])
            ->striped();

I need to dispatch an event to let another livewire component on the page, containing an Infolist, know that a row has been clicked and that it should display data relevant to that row.
However, it seems that clicking on the row or the action button resets the component completely.
I noticed this since the component starts out hidden, and is displayed when it receives an event that's dispatched from a job queued by a third livewire component on the page containing a Form. Clicking any row hides the Table again, suggesting it's refreshing its $hidden property.
Maybe it's wrong from a design standpoint in the first place?
I'm just really lost
Solution
I don't know what kind of trigger the action fires that causes the component to refresh
It's a Livewire request. Livewire components rerender on requests
Was this page helpful?