function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ben Swift 19Ben Swift 19 

lightning-input autosuggest

I have a LWC with a lightning-combobox whose options are populated via an apex query of records. The record list changes depending on the user accessing the LWC. There is one user for whom the query returns 400+ records, which causes the page to take a long time to render.


I'd like to refactor the LWC to not populate the options on page load, but rather allow the user to enter text into an input, have JS filter the returned records from apex based on the input and give them a autosuggest list consisting of the filtered records (similar in experience to html input type="search" (https://www.htmlquick.com/reference/tags/input-search.html)). I haven't found any great examples to pull from cursory googling. Before I go into building this from scratch, I figured I'd ask here if anyone has any helpful examples to point to?

Danish HodaDanish Hoda

Hi Ben,

You can simply query the records like - 

SELECT Id, Name FROM <Obj> WHERE <field> LIKE '%<SearchString>%'