Search & Pagination bug - stops working after a few requests?!

Hey there,

I’m using Livewire to great success and love it, but I’ve found a bug which is preventing me from pushing this to production unfortunately.

What happens:

I have a search input which on submit queries a model and returns the results to Livewire using WithPagination.

This works great for the first few requests with pagination working, but after a number of requests (sometimes 3, sometimes 10, there’s no set number) the requests stop being sent to Livewire and the Livewire controller stops being called completely.

It’s almost like the submission event is totally ignored after a set number of requests. The only way to get it working again is to hard refresh the page.

The code:

Here is the input the search query is being entered into:

<input id="searchInput" type="search"
    wire:keydown.enter="$emit('submitSearch', document.getElementById('searchInput').value)">

And here is the Livewire controller which is receiving the input:

<?php

namespace App\Http\Livewire;

use App\Influencer;
use Livewire\Component;
use Livewire\WithPagination;

class InfluencerSearch extends Component
{

    use WithPagination;

    protected $listeners = ['submitSearch' => 'submitSearch'];
    public $searchInput;

    public function submitSearch($term) {
        $this->gotoPage(1);
        $this->searchInput = $term;
    }

    public function render()
    {
        if (empty($this->searchInput)) {
            return view('livewire.influencer-search', ['results' => '']);
        } else {
            return view('livewire.influencer-search', ['results' => Influencer::where('biography', 'LIKE', '%' . trim($this->searchInput) . '%')->paginate(6)]);
        }
    }
}

As said, the first few requests work pefectly which is why this is really weird. I’m using Laravel 7 and the latest version of Livewire.

Any thoughts?

Hello, did you manage to get to the bottom of this? I too am experiencing something similar.

Thanks