View Full Version : focus comes before blur event

10 Nov 2010, 3:43 AM
I have two comboboxes in a form. In the focus-eventhandler of combo2 I read the value of combo1 and react to it.
When tabbing through the fields of the form with keyboard events everything works fine. But when I use the mouse the events appear in the wrong order.
Steps to reproduce:
- Enter Text in the combo1
- Click with the mouse in combo2
Now I get combo2->focus first and then combo1-blur. So in the focus-eventhandler I get the old value of combo1.

Is this a bug or normal behaviour? How can I bypass this?

10 Nov 2010, 4:21 AM
This is normal behaviour.

The normal focus/blur handling for a combobox wouldn't work, because a combobox consists of multiple elements (otherwise you would get a blur event when you clicked the trigger).
This is why Ext uses a different method to determine when a combobox is blurred, but unfortunately this means that a focus event for another component can fire before the combobox blur event.

10 Nov 2010, 5:26 AM
Is there a workaround for this?
My customer who is a large company and publishes the application in the internet wants a solution.

10 Nov 2010, 5:39 AM
You could force the blur in the focus handler, e.g.

combo2.on('focus', function(){
var value1 = combo1.getValue();

10 Nov 2010, 5:53 AM
thank you very much Condor. Sometimes solutions are that easy and one does not see them or like we say in Germany: I do not see the forrest because of all the trees that are around me.

10 Nov 2010, 6:04 AM
The dutch expression is identical.