Table Action always the same record
I have the problem that my custom callback for the Action table always uses the first record. How can I fix this?
Action::make('edit')
->action(function (UserItem $record): void {
$this->emit('doEmitCallback', [
'file' => $record->id
]);
})
->color('secondary')
->icon('heroicon-s-pencil'),
7 Replies
What type of action is this?
Its inside the getTableActions function (custom livewire table component) as a Filament\Tables\Actions\Action
Then the $record should only have 1 record and that should be the record being clicked. You are saying it's returning the first record in the row? Wondering if it's still an issue in V3. Could you test the same scenario, I do recall something similar last year with people. Make sure it is the latest V2 release you are using too.
Its the latest v2 version, I allready check this. Is there any solution to trigger a emit with the right Record?
v3 works, but we need to use v2 for the current project.. @Dan Harrin any ideas?
this feels like quite a serious issue and im surprised because i havent seen it reported before
and since v2 has been updated in a while why would it break now
i would encourage you to debug it and try submitting a bug fix pr that i would be happy to release
but as i said, i kinda doubt this is an issue with filament so i dont really think im going to spend time investigating myself, as its v2
@Dan Harrin I have the same issue on v3 with a table Action (inside a panel, not as OP stated with custom livewire component). First time I trigger the Action, the correct record is injected, afterwards this same record is used for each row (and no loading indicator is shown)...
It seems as if all the record Ids are the same after the table gets refreshed after the action succeeded / is cancelled
wire:click="mountTableAction('manage-tags-table', 'xxxxxxx')" // xxx is an individual id after page load for each record. After the table gets refreshed through the table action, all click handlers receive the ID or the record of the row that has been selected for the first run of the action....
Probably a Dom Diffing sideeffect! Happy to supply code, if needed
@Dan Harrin Update: after further investigation, it seems to occur only, if you have actiongroups within actiongroups.
Reproduce with out-of-the-box delete Action:
$table->actions([
ActionGroup::make([
ActionGroup::make([
DeleteAction::make(),
//RestoreAction::make()
])->dropdown(false)
])
])
Any Idea? We have a lot of actions, which is why we grouped them into separate logical groups in one larger dropdown...
Please open an issue with a reproduction repository