Support from Acquia helps fund testing for Drupal Acquia logo

Comments

queenvictoria’s picture

Status: Active » Needs review
FileSize
729 bytes

Patch attached

drunken monkey’s picture

Status: Needs review » Needs work

With the patch applied, auto-submit doesn't work for me anymore. Does it work for you? And, have you also checked whether it works without Views AJAX enabled?
In my opinion, your code looks better than the old one so if it worked I'd definitely use it (unless someone else objects) – but it doesn't seem to, for whatever reason. (I couldn't find any obvious one, at least, and the code doesn't throw any errors either.)
Also, which browser do you use? Have you checked in others? I'm using Firefox 23.0. Maybe it's a compatibility issue? In that case, using jQuery is of course usually the safer option …

queenvictoria’s picture

Status: Needs work » Needs review
FileSize
796 bytes

Yeah I noticed that. After a lot of clicking and submitting I've settled on clicking the submit button. Not sure what you think about this but it is what I can get to reliably do the following.

  1. Arrow down results and press return
  2. Click a result
  3. Enter some text and press return (while autocomplete is still loading--my original error)
  4. Actually use the button
drunken monkey’s picture

Status: Needs review » Needs work

Ah, much better, thanks! Now nearly everything seems to work fine – except for your item 1, when AJAX is enabled. For me, this doesn't insert the autocomplete value before it submits the form via AJAX – e.g., if you type "fo", select the suggestion "foo" and press [Enter], the form will be submitted with "fo".

I tried to find out where this went wrong, but couldn't find it, sorry. Do you have some idea, maybe?

Also, what's the rationale between the new return true in the click handler?

das-peter’s picture

Damn, that was a nasty one.
It looks like the ajax handling of the form is triggered before / during the autocomplete when hitting enter and thus misses the updated form value.
To stop enter from firing the ajax handling on its own I extended Drupal.jsAC.prototype.onkeydown().
Now $(':submit', input.form).trigger('click'); really is the function that triggers the ajax handling after the new form value is set.

I've created two patches. One that overwrites Drupal.jsAC.prototype.onkeydown() as it was done before with Drupal.jsAC.prototype.onkeyup() and one that extends rather overwrites.
Up to you what you like more - I personally prefer to copy / paste as few code as possible thus I'd try the extend patch ;)

drunken monkey’s picture

Works fine for me, thanks for the great work!
Were you able to reproduce the error before applying any patches? For me, everything was working fine anyways so I'm not sure if this really fixes anything. However, it does clean up the code a little, I guess. (Just to clarify, the one with the "-optimized" suffix is the one you'd prefer?)

The best thing would of course be if the original issue creator could try out your patch(es), but it seems he's not following the issue anymore.

das-peter’s picture

Were you able to reproduce the error before applying any patches?

Hmm, can't exactly remember but my comment "Damn, that was a nasty one." suggests that it was an issue for me too and a nasty one :D

Just to clarify, the one with the "-optimized" suffix is the one you'd prefer?

Yes

drunken monkey’s picture

Status: Needs review » Fixed

OK, since it seems to work fine and apparently fixes a problem for some, I just committed the patch. We'll just have to see if complaints about the change pop up, I guess. ;)
Anyways, thanks a lot for your work, both of you!

Status: Fixed » Closed (fixed)

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