solidusio / solidus_starter_frontend

🎨 Rails-based starter kit for your Solidus storefront.
BSD 3-Clause "New" or "Revised" License
56 stars 37 forks source link

Autocomplete main search with products and taxons #300

Closed kennyadsl closed 1 year ago

kennyadsl commented 1 year ago

Adds some very basic autocomplete functionalities to our main search input. It returns results for what has been typed so far for products and taxons, up to 5 for each type.

For products, it also allows users to see all results for the given keyword, falling back to the standard search.

Once the suggestions box appears, some very basic UX allows to navigate results:

Screenshot 2023-02-02 at 14 52 31

Thanks @elia for guidance and help during its development.

Description

This feature uses stimulus to submit the form on every key pressed in the search input (if > 2 chars) and add some UX to navigate the results.

Turbo stream will take care of updating the results section with the suggestions retrieved from the new specific controller action introduced.

Motivation and Context

We want to provide a basic implementation for stores that want to add autocomplete capabilities to their store. This solution is basic but highly customizable based on each store's specific needs.

How Has This Been Tested?

Tested manually and via specs (see PR changes).

Types of changes

Checklist: