Livewire Search or Filter Not Updating the Table? wire:model.live, Debounce, Pagination and wire:key
You add a search box and a status dropdown above a list of invoices (or orders, or users). You type, and nothing happens. Or the results only change when you click to page 2. Or they change once and then always show the same rows. Almost every case comes down to a handful of causes, and the biggest one is a default that changed in Livewire 3. This checklist is written for Livewire 3 and 4 and notes where they differ.
Quick reference
| Symptom | Likely cause | Check |
|---|---|---|
| Typing does nothing until you click something | wire:model is deferred by default |
1 |
| A request on every keystroke | No debounce | 2 |
| Dropdown filter does nothing (Livewire 4) | .change / .blur without .live |
3 |
| Always the same results | Query runs in mount() or is stored once |
4 |
updatedSearch() never fires while typing |
Same deferral as check 1 | 1, 5 |
| Search on page 3 shows "no results" | Page not reset when the filter changes | 6 |
| Rows show stale values or jump around | Missing or non-unique wire:key |
7 |
| Nothing at all reacts | More than one root element, or Livewire's JS isn't loaded | 8 |
☐ 1. Use wire:model.live on the search input
From Livewire's docs: "By default, Livewire will only send a network request when an action is performed (like wire:click or wire:submit), NOT when a wire:model input is updated." To update as the user types, use .live:
<input type="search" wire:model.live="search" placeholder="Search invoice #">
If you're upgrading from Livewire 2, the upgrade guide says: "In Livewire 3, wire:model is 'deferred' by default... To achieve the same behavior as wire:model from Livewire 2, you must use wire:model.live." Old tutorials that use plain wire:model for live search behave differently on 3 and 4.
☐ 2. Add a debounce that fits
With wire:model.live, Livewire "adds a 150 millisecond debounce to server updates" by default. For a search box that queries the database, a longer pause often feels the same and sends fewer requests:
<input type="search" wire:model.live.debounce.300ms="search">
☐ 3. Make the dropdown filter live too (watch the Livewire 4 change)
For a <select>, wire:model.live="status" sends the update as soon as the option changes, on both versions. The .blur and .change modifiers differ:
- Livewire 3:
.changesends "a network request ... as soon as a user selects a new option", and.blursends on blur. - Livewire 4:
.blurand.changeonly change when the value syncs. To also send a request, the docs add.live:wire:model.change.live="state".
If a filter works on 3 and stops on 4, look for a bare .change or .blur.
☐ 4. Filter where it runs on every request
mount() "only runs once per component lifecycle". If you query there, or store the results in a property once, the list never changes. Run the query in render(), or in a #[Computed] method that you read from the view:
public function render()
{
return view('livewire.invoice-list', [
'invoices' => Invoice::query()
->when($this->status !== 'all', fn ($q) => $q->where('status', $this->status))
->when($this->search !== '', fn ($q) => $q->where('number', 'like', '%'.$this->search.'%'))
->latest('issued_at')
->paginate(20),
]);
}
Note: like with user input treats % and _ as wildcards, and case sensitivity depends on your database collation. Escape or normalise the term if that matters for your data.
☐ 5. Hooks run when the update reaches the server
updated() is "called after updating a property", and updatedSearch() runs for $search alone. With a deferred wire:model, the update only reaches the server with the next action, so the hook seems "dead" while you type. .live (with or without a debounce) fixes both.
☐ 6. Reset pagination when a filter changes
The pagination docs: "When sorting or filtering results, it is common to want to reset the page number back to 1." Without that, someone on page 3 who searches for one invoice sees an empty page:
use Livewire\WithPagination;
class InvoiceList extends Component
{
use WithPagination;
public string $search = '';
public string $status = 'all';
public function updatedSearch(): void
{
$this->resetPage();
}
public function updatedStatus(): void
{
$this->resetPage();
}
}
To keep the filters after a refresh or in a shared link, add the #[Url] attribute (use Livewire\Attributes\Url;) above $search and $status. Livewire then stores them in the query string and reads them back on page load.
☐ 7. Key every row by its record ID
"When looping through data in a Livewire template using @foreach, you must add a unique wire:key attribute to the root element rendered by the loop." Use the record's ID, not the loop index. When a filter removes rows, index keys can make Livewire reuse the wrong DOM rows:
@foreach ($invoices as $invoice)
<tr wire:key="invoice-{{ $invoice->id }}">…</tr>
@endforeach
☐ 8. One root element, and Livewire's JavaScript on the page
- Livewire's component docs list a "Missing root element in your Blade template (Livewire requires exactly one root element)" as a common cause when a component doesn't render. Wrap the search box, filters, table and links in a single
<div>. - Livewire 3 and 4 inject their JavaScript automatically on pages that contain Livewire components, unless
inject_assetsis turned off inconfig/livewire.php. If nothing reacts at all, open the browser's network tab and check that typing sends requests. If it doesn't, check for console errors and that config option.
Putting it together
<div>
<div class="flex gap-2">
<input type="search" wire:model.live.debounce.300ms="search" placeholder="Search invoice #">
<select wire:model.live="status">
<option value="all">All statuses</option>
<option value="draft">Draft</option>
<option value="sent">Sent</option>
<option value="paid">Paid</option>
<option value="overdue">Overdue</option>
<option value="void">Void</option>
</select>
</div>
<table>
@forelse ($invoices as $invoice)
<tr wire:key="invoice-{{ $invoice->id }}">
<td>{{ $invoice->number }}</td>
<td>{{ $invoice->status }}</td>
</tr>
@empty
<tr><td colspan="2">No invoices match.</td></tr>
@endforelse
</table>
{{ $invoices->links() }}
</div>
If you're building an invoice portal
Billstack ($29) is a pack of Livewire components for customer and admin billing portals. According to its product page, it includes a customer invoice list with a live search box and status filter (it filters the rows you pass in; it doesn't paginate), a line-item editor (add, remove and reorder lines with a live subtotal), a tax summary with an inclusive/exclusive toggle, a payment status badge (draft, sent, paid, overdue, void) and recurring-schedule fields. It requires PHP ^8.2, Livewire 3 or 4 (tested on 3.8.10 and 4.4.7) and Laravel 10+, with Alpine and Tailwind. It comes with a PHPUnit suite and a local demo with fake data. It's UI only: no payment provider, tax engine, PDF generation or email delivery. You wire in your own data and billing backend.
Sources
- Livewire docs, wire:model (deferred default,
.live, debounce,.blur/.change): https://livewire.laravel.com/docs/wire-model - Livewire 3 docs, Upgrade guide (wire:model changes): https://livewire.laravel.com/docs/3.x/upgrading
- Livewire docs, Lifecycle hooks (
mount,updated): https://livewire.laravel.com/docs/lifecycle-hooks - Livewire docs, Pagination (resetting the page): https://livewire.laravel.com/docs/pagination
- Livewire docs, URL query parameters (
#[Url]): https://livewire.laravel.com/docs/url - Livewire docs, Components (troubleshooting): https://livewire.laravel.com/docs/components
- Livewire 3 docs, Components (
wire:keyin loops): https://livewire.laravel.com/docs/3.x/components - Stack Overflow, Using Livewire 3 and Laravel 10.10: simple input data binding is not working: https://stackoverflow.com/questions/76756034
- Stack Overflow, Livewire search does not rerender the results: https://stackoverflow.com/questions/77035640