Gravatar for slangevin@coveo.com

Question by Simon, Apr 15, 2019 8:28 PM

Disable query suggestions on an empty box

Using ML query suggestions, can I prevent the suggestion box to appear when I have not yet entered a letter?

I don't see any options for that on the component.

1 Reply
Gravatar for kmpungi@coveo.com

Answer by Karel Mpungi, May 2, 2019 7:20 PM

As of now, there is no way to do that out of the box. You are able to hide the suggestions through some custom javascript which could add a CSS class with display:none when the searchbox has nothing typed in it. You would then remove this class when something has been typed. Please note this method does not increase performance. The div which hosts the suggestions has the class of magic-box-suggestions and also has the magic-box-hasSuggestions class when suggestions are present. Hiding suggestions just prevents them from being visible and selectable by the mouse. Users would still be able to select these suggestions by pressing the arrow keys when the searchbox has focus.

Ask a question