I use Search API autocomplete in combination with Search API pages, I made a global search that has an exposed block in the header region of my website.

Say for example a user visits the homepage of my site and typs something in the search box (for example "te"). a pop-up with suggestions is shown (for example "test", "testing"). When the user hits enter he goes to the search page. the search page search box is automatically filled automatically (with "te", "test" or "testing" depending on the user his action) and now this.populatePopup(); will run again (line 39 search_api_autocomplete.js) because input.value.length > 0. This seems a little odd to me.

Is there a way to fix this?

Kind regards,

f0ns

Comments

f0ns’s picture

Issue summary: View changes
f0ns’s picture

Title: his.populatePopup(); gets triggered to often » this.populatePopup(); gets triggered to often
drunken monkey’s picture

So you mean that when the search page with results loads, the popup will immediately show again?
I cannot reproduce this, and also the code suggests this should only happen when a keypress is registered in the keywords input field.

f0ns’s picture

Yes exactly, we have this issue on all our websites.

(tested in: Firefox, Chrome, Safari).

Looks like it also gets triggered when the value of the block is used to fill out the field on the searchpage.

drunken monkey’s picture

Is one of them maybe publicly visible? Could you post a link?
Maybe it is some other contrib module's JS interfering? Can you also reproduce in a clean installation of Drupal, with just the necessary modules enabled?

f0ns’s picture

I also have this on a clean install with only the necessary module installed. I mailed you the link.

drunken monkey’s picture

Status: Active » Closed (works as designed)
jQuery(document).ready(function($) {
  $('input:text[name=keys_1]').keyup(function() {
        $('div .search-results').removeHighlight();
        $('div .search-results').highlight($(this).val());
  }).keyup();
});;

Next time, please debug your own Javascript!

f0ns’s picture

Thanks for the help!