[FIX] ignore blur event on m2o input during autocompletion or if a sub-popup is open
jquery.ui.autocomplete does quite a bit of focus-setting during and around itself, leading to blur events being triggered outside expectations (e.g. after an action has been selected and the dropdown has been closed due to the action opening a popup whose content gets focused somehow). Really, the guy who implemented o2m's autosave-on-blur should be shot. Wait, that would be me. bzr revid: xmo@openerp.com-20120808151843-et2r8hplxxyqc7v6
This commit is contained in:
@@ -2826,7 +2826,21 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
||||
tip_def.reject();
|
||||
}
|
||||
};
|
||||
this.$input.focusout(anyoneLoosesFocus);
|
||||
var ignore_blur = false;
|
||||
this.$input.on({
|
||||
focusout: anyoneLoosesFocus,
|
||||
focus: function () { self.trigger('focused'); },
|
||||
autocompleteopen: function () { ignore_blur = true; },
|
||||
autocompleteclose: function () { ignore_blur = false; },
|
||||
blur: function () {
|
||||
// autocomplete open
|
||||
if (ignore_blur) { return; }
|
||||
if (_(self.getChildren()).any(function (child) {
|
||||
return child instanceof instance.web.form.AbstractFormPopup;
|
||||
})) { return; }
|
||||
self.trigger('blurred');
|
||||
}
|
||||
});
|
||||
|
||||
var isSelecting = false;
|
||||
// autocomplete
|
||||
@@ -2869,7 +2883,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
||||
}
|
||||
isSelecting = false;
|
||||
});
|
||||
this.setupFocus(this.$input.add(this.$follow_button));
|
||||
this.setupFocus(this.$follow_button);
|
||||
},
|
||||
render_value: function(no_recurse) {
|
||||
var self = this;
|
||||
|
||||
Reference in New Issue
Block a user