Hi daniel,

here is a problem that many of my users reported:

search forms with only one autocomplete-field require 2 hits on enter to submit the form
and I really understand that this is necessary for forms with multiple inputs because
the first return takes the suggestion into the input and the second return submits the
form but this behavior is really annoying when you intent to submit your search on
first return. maybe this behavior appeared to you on api.drupal.org and as you are a
module developer I suppose you use that search box quite often :)

I know that must be some sort of standard-drupal JS but it would be very nice if one
had in autocomplete-finder setting an option to change if one or two returns are
necessary to submit the form and depending on this setting the standard-drupal JS
or maybe a custom JS is used...

Comments

danielb’s picture

Tried to change this behaviour before but I didn't get anywhere. Patches welcome.
Using a completely custom JS may be worth considering, but I will have to think about it a little more.

dsms’s picture

/misc/autocomplete.js automaticly attaches its functionality on every input with class="autocomplete".

the easiest way would be to fork autocomplete.js to lets say singleautocomplete.js and change the following lines:

25-29:

Drupal.autocompleteSubmit = function () {
return $('#autocomplete').each(function () {
this.owner.hidePopup();
}).size() == 0;
};

to:

Drupal.autocompleteSubmit = function () {
return $('#autocomplete').each(function () {
this.owner.hidePopup();
this.form.submit();
}).size() == 0;
};

this works very well.

now the complicated part: if configured in Finder, Autocomplete Finder should output other css-classes,
for example <input class="singleautocomplete" ...> instead of <input class="autocomplete" ...>
and the forked singleautocomplete.js now has to look for "singleautocomplete" instead of "autocomplete".
when done, just copy the singleautocomplete.js to your module-folder and push it to $scripts
via drupal_add_js() if configured in Finder :)

danielb’s picture

Doesn't work for mouse clicks.... I'm trying a few things now

danielb’s picture

Status: Active » Fixed

I've added this in alpha 20, it's actually a config option in the finder element form settings.
Might need to rebuild theme stuff first

dsms’s picture

wow! that are great news! thank you

dsms’s picture

sorry, I don't find this setting. I created a new node finder, with setting "Redirect to the only result node,..." plus an Autocomplete
field but the autocomplete settings are the same as in alpha19 :( I thought it would be in "Finder form element settings"

danielb’s picture

Sorry about that, seems none of the changes commited yesterday made it into the release? :/ There should be a good one up soon.

Gyt’s picture

Status: Fixed » Needs work

It's may be a very good feature, but now it's not work right.

With option "Submit upon selection" autocomplete field submit the form, when:

  • user click on this field and later click on some place out of it;
  • user write a word in this field and it isn't in suggested autocomplete values.
danielb’s picture

I believe I have solved this. I will add it to the next commit.

danielb’s picture

Status: Needs work » Fixed

OK it is much better now.

Gyt’s picture

Sorry, but alpha25=alpha26 :)

danielb’s picture

sorry about that, I was excited I fixed it and forgot to commit the code.

Gyt’s picture

Version: 6.x-1.0-alpha13 » 6.x-1.0-alpha27
Status: Fixed » Active

Oh, another error.
When I use finder block with option "Submit upon selection", all autocomplete forms on page submit their forms upon selection. For example, autocomplete taxonomy submit a node, when I add term.

danielb’s picture

I'm not sure I follow. The autocompletes that aren't meant to submit upon selection do so because there is another autocomplete on the page with this feature?

Gyt’s picture

Yes. I disabled finder block on node form pages, but it isn't a good solution.

danielb’s picture

Status: Active » Fixed

OK there was a bug with an object being called the same thing as the original .js, It's fixed. Thanks.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Version: 6.x-1.0-alpha27 » 7.x-2.x-dev
Category: feature » bug
Status: Closed (fixed) » Active

issue pops up again on D7

danielb’s picture

Version: 7.x-2.x-dev » 6.x-1.0-alpha27
Category: bug » feature
Status: Active » Closed (fixed)

...