Autocomplete is a special interaction which can happen on multiple options can be suggested for a single command.
We’ve implemented this functionality using a simple tree search algorithm within a nested options tree.
Example
In this example, the option list
will autocomplete with the cheeses gouda
, parmesan
, and harvarti
.
Using Focus
The focus
object can be used to refine the options. For example, if the user types g
, the focus object will be g
.
We can filter the cheeses based on the focus object, and return only the cheeses that start with the focus object.
You can do a lot more with the focus object, such as performing API calls, or implementing a fuzzy search.