When you view a resultpage 2 from a paginated livewire result and change the filter or search, the generated result stays on resultpage 2. This is usually not desired.
To change this behaviour and reset the Resultpage to page 1 for every new search, you can add this function to your your Livewire model:
public function updating($key): void
{
$this->resetPage();
}
If you have more than one filter or search variables, and need to stay on the same page for some of them, you can reset the page for specific variables only like this:
public function updating($key): void
{
if ($key === 'search') {
$this->resetPage();
}
}
The above code will only jump to the first page of the results, if you change your $this->search
variable. For every other variable change it won’t trigger.