Hi All,

I'm having a problem with the current implementation of the autocomplete. Let 
me explain first:

I have a form with a autocomplete field (AutoCompleteBehavior) and a save 
AjaxButton on it. Apart from this, this field has a onchange AjaxEventBehaviour 
to do some validation on the backend and possibly make some changes to the 
field.

When I fill in the field and without leaving the field (and thus no blur event 
has been triggered yet) I click on the save AjaxButton.
What I'd expect to happen is the following event flow:

-          blur: the field has been blurred

-          change: the field has been changed

-          click: the click on the save button

Instead this is what happens:

-          blur

-          click

-          change

Further investigation tells me that this is because of the 
wicket-autocomplete.js implementation for the blur event handler.
wicket-autocomplete.js can be found on: 
\wicket-head\wicket\wicket-extensions\src\main\java\org\apache\wicket\extensions\ajax\markup\html\autocomplete

On line 91 the blur event hander can be found:

  Wicket.Event.add(obj, 'blur', function (jqEvent) {
    window.setTimeout(hideAutoComplete, 500);
  });

This wraps the hideAutoComplete field in a setTimeout of 500 ms. In the 
hideAutoComplete, the change event is triggered (line 438).
The setTimout call causes the change event to be executed after the click 
event, leaving me with a partially saved form.

To fix this, I could remove the setTimeout functionality from the blur event 
handler. This will call hideAutoComplete immediately. This change will cause 
the autocomplete dialog to be closed immediately and leaving us with the right 
event stack. I've not noticed any other side effects.

I have a patch ready, but I'd like to have your thoughts on this. When 
necessary, I can create an issue on https://issues.apache.org and send a pull 
request.

All code has been taken from latest greatest Wicket on Github.


With kind regards,

Elger van Boxtel
Agile Developer
--------------------
Planon B.V.
Postbus 38074
6503 AB Nijmegen
Wijchenseweg 8
6537 TL Nijmegen
Nederland
T: +31 (0) 24 750 7727
F: +31 (0) 24 642 2942
E: [email protected]<mailto:[email protected]>
W: www.planon.nl<http://www.planon.nl/>
W: http://elgervanboxtel.nl
LN: LinkedIn<https://nl.linkedin.com/in/elgervanboxtel>
GH: GitHub<https://github.com/elgervb>


This e-mail and any attachment is for authorized use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender.
[cid:[email protected]]Please consider the environment before 
printing this e-mail.

Reply via email to