mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2026-02-05 09:45:12 -05:00
feat: implement autocomplete functionality for park search with keyboard navigation
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Livewire;
|
||||
use App\Models\Park;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
@@ -49,6 +50,17 @@ class SearchComponent extends Component
|
||||
$this->filtersApplied = $this->hasActiveFilters();
|
||||
}
|
||||
|
||||
#[On('suggestion-selected')]
|
||||
public function handleSuggestionSelected($id, $text): void
|
||||
{
|
||||
$park = Park::find($id);
|
||||
if ($park) {
|
||||
$this->search = $text;
|
||||
$this->filtersApplied = $this->hasActiveFilters();
|
||||
redirect()->route('parks.show', $park);
|
||||
}
|
||||
}
|
||||
|
||||
public function updatedLocation(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
|
||||
Reference in New Issue
Block a user