From b83db271354ee8ecabf4a39c96f3a187dd5535d5 Mon Sep 17 00:00:00 2001 From: MOENS Alexandre Date: Tue, 21 Aug 2018 12:00:49 +0200 Subject: [FIX] web: JournalDashboardGraph widget crash Mk.II Hardening of commit:995610c065bf0242cb5023cfad2940234395739e The JournalDashboardGraph requires nv, which is lazyloaded. However it requires nvd3.js which is loaded after nv.d3.js. A function called in destroy is defined by nv.d3.js, which can make the crashhappen with the right (wrong) timing. opw 1873749 --- addons/web/static/src/js/fields/basic_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index d624651ac85..71aab9f7992 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -2055,7 +2055,7 @@ var JournalDashboardGraph = AbstractField.extend({ return this._super.apply(this, arguments); }, destroy: function () { - if ('nv' in window) { + if ('nv' in window && nv.utils && nv.utils.offWindowResize) { // if the widget is destroyed before the lazy loaded libs (nv) are // actually loaded (i.e. after the widget has actually started), // nv is undefined, but the handler isn't bound yet anyway -- cgit v1.2.3 From c63630d41622412261401300775c0f720e6acbef Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 17 Sep 2018 12:12:41 +0200 Subject: [FIX] web: datepicker: correctly use lib The datepicker lib has been updated to tempus dominus (BS4) recently, but our code hasn't been adapted correctly to the requirements of the new version of the lib. As a consequence, the datepicker didn't close itself when the input was focused out anymore. This required a slight change in the DomainSelector widget as it produced a crash when a focused datepicker widget is removed from the DOM (before the datepicker is destroyed), e.g. by a call to html() on one of its parent. Task 1878254 --- addons/web/static/src/js/fields/basic_fields.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index d3ca9a653fd..0a397a65047 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -525,6 +525,25 @@ var FieldDate = InputField.extend({ return $.when(def, this._super.apply(this, arguments)); }, + //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + + /** + * Asks the datepicker widget to activate the input, instead of doing it + * ourself, such that 'input' events triggered by the lib are correctly + * intercepted, and don't produce unwanted 'field_changed' events. + * + * @override + */ + activate: function () { + if (this.datewidget) { + this.datewidget.focus(); + return true; + } + return false; + }, + //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- -- cgit v1.2.3