Download & Extend

When you select a suggested keyword the search should start automatically!!!

Project:Keyword Autocomplete
Version:6.x-1.0-beta1
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

Hi,

this is a great module. Thanks a lot! (BZW, I've just switched from Search Autocomplete).

I'm not sure if this is a Bug-report or a Feature-request. Here it is:

Right now while I type a search keword several suggestions will pop out, and when I select one of those suggestions (with a mouse or the Enter button), nothing happens!!! This is disorienting and unintuitive, especially for the theme's search boxes that do not feature the "Search button". What I would suggest is that once one of the autocompleted suggestions is selected the search should start instantly! Check out how it is done on www.Wikipedia.org or www.YouTube.com or www.Facebook.com and many other sites where such functionality exists -- the search process starts as soon as one of the suggestions is selected!

Because of the standard set by those major sites, people are already accustomed to expect the search process to start as soon as one of the keywords is selected.

Comments

#1

I too would like to see this feature. The number of times i have used my own site and done the same thing is countless.

#2

Also ... www.Google.com has recently introduced this functionality and with exactly the same process as I described it above, so there you have it. I guess this is a web *standard* of how search autocomplete should behave.

#3

Version:5.x-1.0» 5.x-1.x-dev

I agree this would be nice to see...

#4

It could be that this simply isn't possible given Drupal's implementation of autocomplete. There is currently a discussion about enhancing autocomplete but I don't know that this has come up: #125231: Enhance autocomplete feature

#5

Having said that we should be able to make it work with a little bit of JS trickery- api.drupal.org manages to do it with the following snippet:

Drupal.behaviors.apiAutoComplete = function (context) {
  $('#api-search-form:not(.apiAutoCompleteProcessed)', context).addClass('apiAutoCompleteProcessed').each(function () {
    // On the first focus.
    $('#edit-search', this).attr('autocomplete', 'off').one('focus', function () {
      var $this = $(this);
      // Prefetch list of objects for this branch.
      $.getJSON(Drupal.settings.apiAutoCompletePath, function (data) {
        // Attach to autocomplete.
        $this.autocomplete(data, {
          sort: function (a, b) {
            return a.value.length - b.value.length;
          },
          matchContains: true,
          max: 200,
          scroll: true,
          scrollHeight: 360,
          width: 300
        }).result(function () {
          $this.get(0).form.submit();
        }).focus();
      });
    });
  });
};

I am no JS guru however, so someone else might need to take the lead on this if you want it done soon.

#6

Version:5.x-1.x-dev» 6.x-1.0-beta1
Status:active» needs work

I needed this functionality too, so to get it done quickly I borrowed some code from the finder_autocomplete module.

I have attached a patch for the drupal 6 version which seems to work for me so far.

AttachmentSize
keyword_autosubmit.patch 11.6 KB

#7

Thank you very much, your patch worked great :) I now have this functionality working with Drupal 6.16.

#8

I added the patch, and although it worked, I noticed a couple of issues.

Now this may have been an error on my part in the, though it was checked.

Using IE8 so it may be some limitation (lots of modules)

I was getting the autocomplete search box appearing in various places it should not.
My Wysywig Module, and TinyMCE were disabled.
Views Ajax refresh was broken

Hope this will help diagnose, or at least provide warnings

Reverting to the original code , restored functionality

#9

Pretty simple fix I've been using. Just add this to your theme's script.js:

$(document).ready(function() {

  /**
   * Puts the currently highlighted suggestion into the autocomplete field
   */
  Drupal.jsAC.prototype.select = function (node) {
    this.input.value = node.autocompleteValue;
    this.input.form.submit();
  };

});

This overwrites the function from autocomplete.js ... pretty simple! Oh, and the only difference from the original is the addition of this.input.form.submit();

Hope this helps some poor (unfortunate) soul like myself.

#10

Yes, jmonkfish's solution works for me too. Don't forget to empty your sites cache to make it work though... ;-)

#11

oops...nevermind.

#12

I ended up needing to do some jQuery selectors so that it didn't always submit, for instance on an add/edit node page. You could probably just check the name of the input before submitting the form.

if(this.input.name == 'searchBox'){
  this.input.form.submit();
}
nobody click here