I see 3 possible conflict causes : Filament vs Livewire vs JS.
If you are using Livewire, you should better use AlpineJS rather than Vanilla JS.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi I am trying to implement something probably extremely common. A page has a search box and, on submit, search results are displayed below. The user can click a "heart" icon against items returned - and this should do two things
The first block of the blade (search field) is coded thus
<x-filament-panels::page>
<div>
<form wire:submit.prevent="search">
{{ $this->form }}
<div style="margin-top: 8px;">
<x-filament::button
type="submit"
onclick="hideResults();"
wire:loading.attr="disabled"
wire:loading.class="bg-gray-300 text-gray-600">
<span wire:loading class="animate-pulse bg-gray-500">Processing...</span>
<span wire:loading.remove>Search</span>
</x-filament::button>
</div>
</form>
And the search results is coded thus
<div class="mt-6" id="searchResults" style="opacity: 1; transition: opacity 0.5s;">
@if (!empty($searchResults))
<h2 class="text-lg font-bold">Search Results</h2>
<ul class="mt-4 space-y-2">
@foreach ($searchResults as $result)
<li class="border rounded p-4">
<div class="fi-ta-col-wrp">
<button type="button"
class="flex w-full disabled:pointer-events-none justify-start text-start"
wire:click="toggleState({{ $result->id }},'x')">
<div
class="fi-ta-icon flex gap-1.5 px-3 py-4">
<svg id="heroicon{{ $result->id }}"
style="--c-400:var(--default-400);--c-500:var(--default-500);"
class="fi-ta-icon-item fi-ta-icon-item-size-lg h-6 w-6 fi-color-custom text-custom-500 dark:text-custom-400"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
aria-hidden="true"
data-slot="icon"
onclick="changeIconColor('{{ $result->id }}');">
<path stroke-linecap="round"
stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12Z">
</path>
</svg>
</div>
</button>
</div>
<h3 class="text-md font-semibold">{{ $result->name }}</h3>
<div class="text-sm text-gray-600">
@foreach (preg_split('/(\.\.\.)/', $result->context) as $index => $snippet)
@if (trim($snippet) !== '')
<p class="mb-2">
{!!
($index > 0 ? '...' : '') .
highlightText(trim($snippet), trim($this->searchQuery)) .
($index < count(preg_split('/(\.\.\.)/', $result->context)) - 1 ? '...' : '')
!!}
</p>
@endif
@endforeach
</div>
</li>
@endforeach
</ul>
@elseif ($searchPerformed)
<p class="text-gray-500 mt-4">No matches found.</p>
@endif
</div>
</div>
</x-filament-panels::page>
Now the problem is that when I click the icon (the svg) it fires the onclick which changes the colour (I have omitted the javascript) but IT ALSO seems to change the submit button (to say "Processing") and, although the DB query isn't repeated, the results div is updated again (which then resets the icon to its original colour).
Can anyone help on this?
thanks :) j
Please or to participate in this conversation.