diff options
| author | qsm-odoo <qsm@odoo.com> | 2017-02-02 17:59:19 +0100 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2017-02-03 13:34:03 +0100 |
| commit | 82ef921874ed40fc7b9bb58e5aa6033c46f5958e (patch) | |
| tree | bd0f7e60611fdfe9b932b65eff9b9e5f42c42d4f /addons/web/static/src/js/widgets/model_field_selector.js | |
| parent | 4c408d1d19cc3d8ffecf8e7694e1f38148f42f1c (diff) | |
[FIX] web: handle field selector closing/opening correctly
Ironically, clicking on the dropdown arrow of the field selector was
the only way which was not opening the dropdown. It was indeed added
as pure design element.
This commit handles the opening and closing of the dropdown in a more
robust way... while simplyfing the code too.
Diffstat (limited to 'addons/web/static/src/js/widgets/model_field_selector.js')
| -rw-r--r-- | addons/web/static/src/js/widgets/model_field_selector.js | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/addons/web/static/src/js/widgets/model_field_selector.js b/addons/web/static/src/js/widgets/model_field_selector.js index 109b7ead7df..da8ab8300f6 100644 --- a/addons/web/static/src/js/widgets/model_field_selector.js +++ b/addons/web/static/src/js/widgets/model_field_selector.js @@ -10,32 +10,14 @@ var ModelFieldSelector = Widget.extend({ template: "FieldSelector", events: { // Handle popover opening and closing - "focusin input, .o_field_selector_popover": function (e) { - if (this._hidePopoverTimeout !== undefined) { - clearTimeout(this._hidePopoverTimeout); - this._hidePopoverTimeout = undefined; - return; - } - if (this.$input.is(e.currentTarget)) { - this.showPopover(); - } + "focusin": function () { + clearTimeout(this._hidePopoverTimeout); + this.showPopover(); }, - "focusout input, .o_field_selector_popover": function () { - if (this._hidePopoverTimeout !== undefined) { - return; - } - this._hidePopoverTimeout = setTimeout((function () { - this.hidePopover(); - this._hidePopoverTimeout = undefined; - }).bind(this), 100); - }, - "click .o_field_selector_close": function () { - if (this._hidePopoverTimeout !== undefined) { - clearTimeout(this._hidePopoverTimeout); - this._hidePopoverTimeout = undefined; - } - this.hidePopover(); + "focusout": function () { + this._hidePopoverTimeout = _.defer(this.hidePopover.bind(this)); }, + "click .o_field_selector_close": "hidePopover", // Handle popover field navigation "click .o_field_selector_prev_page": "goToPrevPage", @@ -183,16 +165,20 @@ var ModelFieldSelector = Widget.extend({ this.valid = valid; }, /// The showPopover method shows the popover to select the field chain. It prepares the popover pages - /// before actually showing it. + /// before actually showing it. (if already open, does nothing) showPopover: function () { + if (this._isOpen) return; + this._isOpen = true; this._prefill().then((function () { this.displayPage(); this.$popover.removeClass("hidden"); }).bind(this)); }, /// The hidePopover method closes the popover and mark the field as selected. If the field chain changed, - /// it notifies its parents. + /// it notifies its parents. (if not open, does nothing) hidePopover: function () { + if (!this._isOpen) return; + this._isOpen = false; this.$popover.addClass("hidden"); this.isSelected = true; if (this.dirty) { |
