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.

Constructor

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.

Fields

read only elements:OrderedMap<String, Element>

read only isOpen:Bool

read only selected:String

Methods

chooseSelectedItem ():Void

Triggers the provided or default function when a selected item has been chosen (e.g. ENTER key or mouse click).

close ():Void

Hide the suggestion list by changing its class.

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.

moveSelectionDown ():Void

Move the selection highlight to the next suggestion.

moveSelectionUp ():Void

Move the selection highlight to the previous suggestion.

open ():Void

Show the suggestion list by changing its class.

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.

setSuggestions (items:Array<T>):Void

Allows you to modify the list of suggested items on the fly.