summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-07-08 14:38:53 +0200
committerXavier Morel <xmo@openerp.com>2011-07-08 14:38:53 +0200
commitff19bed2b30015fdbe82e2dca4cf951afacd375f (patch)
treebbc42b68565ad52690cad4ab78c2da8482cfc63a
parent5b9e19e5a629bc6b6099b5cb5ae80dde4b05d0b2 (diff)
[FIX] the keyup event using the return key on a selection widget should not propagate if that [Return] press changed the widget's value
bzr revid: xmo@openerp.com-20110708123853-znak06wgm4uvoi7q
-rw-r--r--addons/base/static/src/js/form.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js
index 2624759dece..7517ec23e01 100644
--- a/addons/base/static/src/js/form.js
+++ b/addons/base/static/src/js/form.js
@@ -1121,8 +1121,28 @@ openerp.base.form.FieldSelection = openerp.base.form.Field.extend({
});
},
start: function() {
+ // Flag indicating whether we're in an event chain containing a change
+ // event on the select, in order to know what to do on keyup[RETURN]:
+ // * If the user presses [RETURN] as part of changing the value of a
+ // selection, we should just let the value change and not let the
+ // event broadcast further (e.g. to validating the current state of
+ // the form in editable list view, which would lead to saving the
+ // current row or switching to the next one)
+ // * If the user presses [RETURN] with a select closed (side-effect:
+ // also if the user opened the select and pressed [RETURN] without
+ // changing the selected value), takes the action as validating the
+ // row
+ var ischanging = false;
this._super.apply(this, arguments);
- this.$element.find('select').change(this.on_ui_change);
+ this.$element.find('select')
+ .change(this.on_ui_change)
+ .change(function () { ischanging = true; })
+ .click(function () { ischanging = false; })
+ .keyup(function (e) {
+ if (e.which !== 13 || !ischanging) { return; }
+ e.stopPropagation();
+ ischanging = false;
+ });
},
set_value: function(value) {
value = value === null ? false : value;