livewire-datatables
livewire-datatables copied to clipboard
Search issue with Callback method when the return value consists HTML element.
I stumbled upon this bug, accidentally, and I'm not having enough time to check the code to submit a pull request.
How to reproduce
First, define the column
public function columns()
{
return [
Column::callback(['role'], function($role) {
switch ($role) {
case "super_admin":
return "<span class='px-1 bg-red-500 text-white rounded text-xs'>Super Admin</span>";
break;
case "admin_irwasum":
return "<span class='px-1 bg-green-500 text-white rounded text-xs'>Admin Irwasum</span>";
break;
... // more roles below
}
})
->label('Tipe Akun')
->searchable(),
];
}
Second, search the data using one character

Third, see the result

Additional notes
- This bug occurs only when one character is searched, if the query is more than 2 characters, the bug won't occur.
- I modified the cell column, only to add DaisyUI's dark mode classes.
text-base-content, so I'm pretty sure it won't affect.
Personal thoughts
I think this bug is regex-related? Because if I see the code using Chrome's inspect element feature, here's what I got:

How I expect the feature should be
The HTML element is left unchanged, only the text inside or the content is changed.