Change search typeahead to search on enter / return, or press on button ( Vue InstantSearch )


The normal search of Vue InstantSearch is typeahead, I wish to change that to press on button or press on enter (submit the form).
In other words, the user types the words and query is only executed if the user press enter on the keyboard or submits the form on the button.

I looked in the documentation and I cannot find documentation to change this behavior. :confused:

Thank you,

Hi @dvz ,

The use case you’re describing is a common one on websites with a search page and a search input in all other pages (e.g. in the header).

If this is indeed the pattern you’d like to achieve, there’s a simple solution:
vue-instantsearch can read its parameters from the URL using the routing feature.

All you need to do with this activated would be to:

  1. Create a search route which uses vue-instantsearch
  2. Have every search input be a form that redirects to this route with query=<typed-query> in the URL

I thought of that, I was hopping that there was a feature to do this without reading the url params, because of the search button :confused: , it woluld be more simple.

  <div slot="submit-icon">🔎</div>

I unfortunately don’t see any simpler solution.
Our instantsearch libraries are built with a realtime search experience in mind.

The advantage of the solution I described above is that you can create such a form on any page, including pages that don’t have vue-instantsearch loaded.

It should have a trigger :confused: , like :

<ais-instant-search searchType="typeahead" >
<ais-instant-search searchType="submit" >

This is indeed a feature that could be added to the library.

The main disadvantage I see with such a solution is that it requires vue-instantsearch to be loaded for a feature that is natively supported by the DOM:

<form method="GET" action="/search">
  <input type="search" name="query" />

I’ve pinged the relevant team to let them know of your feedback, but as I mentioned before, as this is not how we design the search experience Algolia provides, I wouldn’t expect it to be implemented in a near future.