The Suggestions
class owns the suggestion list and controls its behavior.
Public methods exist to modify suggestions, show and hide the menu, move the
selection and choose the selected option, filter on demand, and more.
new (options:SuggestionOptions<T>, classes:FancySearchClassNames)
When you create an instance of Search
, it comes with a public list
field
that is an instance of Suggestions
. In most cases, you will not need to
create an instance of Suggestions
directly.
chooseSelectedItem ():Void
Triggers the provided or default function when a selected item has been chosen (e.g. ENTER key or mouse click).
filter (search:String):Void
Filtering the list happens automatically when the search input is focused, as well as when its value changes. Filtering uses the provided filter function, then the DOM is updated accordingly.
In many cases, you will not need to manually call filter
, but this
method may be useful if your list can be filtered by means outside of the
FancySearch input.
selectItem (?key:String):Void
Move the highlight class to a specific item. If no key is provided, this method clears the selection.
setChooseSelection (fn:SelectionChooseFunction<T>):Void
Allows overriding the onChooseSelection
function at any time.