You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Within the autocomplete compenent, I would like to control the way that results are ordered by providing the autocomplete component with an optional search function.
Currently results are ordered in the same order that they are given within the options prop, however I would like to have the results ordered by specified ranking function that is passed to the autocomplete as an optional prop.
// we need a way to sort the array of strings within filtered, // based on a provided search function passed in as a prop constfiltered=options.filter((optionsName)=>optionsName.toLowerCase().includes(value.toLowerCase()));
for example:
quickSearch=(value: string)=>{constqueryStr=value.toLowerCase();options.toLowerCase().includes(queryStr);constfiltered: string[]=options.filter((optionsName: string)=>optionsName.toLowerCase().includes(value.toLowerCase())).sort((a: string,b: string)=>{// code that will sort the valid results});returnfiltered;};<Autocomplete..// usualy propssearch={this.quickSearch}/>
If a search function is not provided the autocomplete should display results as it is currently doing.
The text was updated successfully, but these errors were encountered:
Within the autocomplete compenent, I would like to control the way that results are ordered by providing the autocomplete component with an optional search function.
Currently results are ordered in the same order that they are given within the
options
prop, however I would like to have the results ordered by specified ranking function that is passed to the autocomplete as an optional prop.for example:
If a search function is not provided the autocomplete should display results as it is currently doing.
The text was updated successfully, but these errors were encountered: