Datalist with ->live() throwing JS Uncaught TypeError When Updating Suggestion List
What I am trying to do:
I'm using a live datalist to suggest potential valid street address based on an entered partial street address and a postal code.
Example: if the user types in "123 Main" they may get suggestions for "123 Main St", "123 Main Ave", "123 Main Blvd", etc.
I've limited the maximum number of suggestions to 5, and there is always at least 1 suggestion available.
What I did:
My issue / the error:
As I enter the first few characters, the suggestions that show in the datalist match what my
getAddressOneOptions()
method is returning. However, as I continue to delete characters and type more characters, so so that the potential suggestions change, the datalist options get out of sync with what my method is returning, until they stop updating entirely when the below exception is thrown:
Initially I thought it might have been a symptom of overlapping requests, but I'm able to reproduce this even with very long (30+ secs) gaps between keystrokes, and I've verified that the server requests are only happening on keystrokes.
I am new to Filament/Livewire, but not new to PHP or Laravel.2 Replies
try it using debounce
Thanks @Leandro Ferreira . Could you explain how applying a
debounce
would help in my situation? I'm already waiting 30+ seconds between typing each letter into the search box. Is that not effectively a manual 30 second debounce?