MedicOneSystems / livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS
https://livewire-datatables.com/
MIT License
1.19k stars 258 forks source link

Cannot replace search highlight tags with exportCallback() #352

Open chrisjimallen opened 2 years ago

chrisjimallen commented 2 years ago

I'm trying to remove the markup that gets added to an exported field value when the search highlighting triggers. For example:

If I perform a search for Hoeger and export the results, my CSV cell data contains:

Hermann-<span class="bg-yellow-100">Hoeger</span>

So I try to perform a str_replace() on $value using the exportCallback() method like so: ( a more obvious example below )

->exportCallback(function ($value) {
     Log::info($value);
     $value = str_replace('span', 'moo', $value);
     return $value;
}),

It just doesn't replace any part of the markup. The str_replace callback works on all other characters in the string, except the search highlight markup. What am I missing? Whats even more confusing is that I'm logging $value and the log file contains the vanilla value without any markup.

chrisjimallen commented 2 years ago

I've created a fix for this here: https://github.com/MedicOneSystems/livewire-datatables/pull/353