octopusthink / nautilus

Inclusive, open-source design system and React component library.
https://nautilus.octopusthink.com
MIT License
2 stars 0 forks source link

ComboBox: Implement autocompletion #229

Open sarahmonster opened 4 years ago

sarahmonster commented 4 years ago

Per our docs:

By default, autocomplete is enabled for ComboBox components. This makes it easier for users to find the option they're looking for from a long or complex list of options. You can disable autocomplete, but that's only recommended for short lists (under seven items). It's generally best to leave enabled, since this allows users to choose the interaction method they're most comfortable with.

The search functionality returns all results, using fuzzy matching. This ensures that users can enter only part of a search term and still find the result they're looking for. For instance, searching a country list for "UK" or "U.A.E" should return "United Kingdom" and "United Arab Emirates", respectively, and "Arab" should return both "Saudi Arabia" and "United Arab Emirates".

When filtering a list by search term, the headings will disappear if all items beneath that heading are also hidden.

Right now, the ComboBox highlights results as you type into it, but doesn't hide the results (or headings!) that don't match the terms.

What we'll want to add here:

There's definitely some hidden complexity in here, especially in terms of allowing fuzzy matches—we may need to provide some way of specifying "hidden" search terms or analogues for each item in a list.

Might be good to tackle in tandem with #228, although they're each probably complex enough to handle on their own!