Problem

The autosubmit functionality for autocomplete forms is broken.

How to replicate

Use search_api_autocomplete (7.x-1.4) and Bootstrap theme 7.x-3.5.
Configure a form to use the autocomplete functionality.
Check if it works.

Proposed resolution

Adjust theme's js overwrite regarding the autocomplete functionality.

Comments

mfernea created an issue. See original summary.

mfernea’s picture

Status: Active » Needs review
StatusFileSize
new511 bytes

Here is the patch.

markhalliwell’s picture

Status: Needs review » Postponed (maintainer needs more info)

I'm not entirely sure what this is attempting to accomplish or why it's necessary.

ivoo56’s picture

Thanks mfernea!
Without your patch api autocomplete is useless on Bootstrap post 7.x-3.0

mfernea’s picture

Status: Postponed (maintainer needs more info) » Needs review

@markcarver:

This is the autocomplete override from search_api_autocomplete/search_api_autocomplete.js

  /**
   * Overwrite default behaviour.
   *
   * Just always return true to make it possible to submit even when there was
   * an autocomplete suggestion list open.
   */
  Drupal.autocompleteSubmit = function () {
    $('#autocomplete').each(function () {
      this.owner.hidePopup();
    });
    return true;
  };

This overrides the default behaviour from misc/autocomplete.js

/**
 * Prevents the form from submitting if the suggestions popup is open
 * and closes the suggestions popup when doing so.
 */
Drupal.autocompleteSubmit = function () {
  return $('#autocomplete').each(function () {
    this.owner.hidePopup();
  }).length == 0;
};

My patch does the same for Bootstrap's autocomplete implementation.

markhalliwell’s picture

Status: Needs review » Needs work

Let's add a comment above return true; explaining this then because it wasn't apparent why diverging from core's code was necessary.

mfernea’s picture

Status: Needs work » Needs review
StatusFileSize
new634 bytes

Here is the updated patch.

  • markcarver committed d8013fa on 7.x-3.x authored by mfernea
    Issue #2695405 by mfernea: Autosubmit broken for autocomplete forms
    
markhalliwell’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ressa’s picture

I couldn't see the 21 February 2017 commit from #8 in the latest release, but in the log I could see that the patch has since been removed. See #2908695: Pressing enter key to select autocomplete option the form gets submitted automatically. for an explanation.

francescosciamanna’s picture

To whom may still run on this issue, I solved it by installing jQuery Update Module.

ressa’s picture

Sadly, installing jQuery Update module didn't fix it for me ... has anybody found a simple work-a-round for it so far?