summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2019-04-11 13:35:49 +0000
committerAaron Bohy <aab@odoo.com>2019-04-12 06:31:11 +0000
commit7bc53ac30ecadbb1e94051edd29c701679cd6de0 (patch)
tree82bcdc638cd2b7de493ed30148f251e389eeacbc /addons/web/static/src
parentcbafa9eddce04353d540450066c844a9c827890a (diff)
[FIX] web: crash in editable lists with date field
Assume an editable list view with a date(time) widget, click to edit a line, focus the date field (the datepicker opens), press ESC: there is a crash in the lib, and the datepicker remains open forever. This fix is twofold: - we added a check in the lib to prevent it from crashing (it is easily reproducible: it crashes when an opened datepicker is removed from the DOM). - we added an event handler of ESC keydown event to hide the datepicker before the field is removed from the DOM.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/widgets/date_picker.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/web/static/src/js/widgets/date_picker.js b/addons/web/static/src/js/widgets/date_picker.js
index 367ab23178d..57c935905e5 100644
--- a/addons/web/static/src/js/widgets/date_picker.js
+++ b/addons/web/static/src/js/widgets/date_picker.js
@@ -15,6 +15,7 @@ var DateWidget = Widget.extend({
'change.datetimepicker': 'changeDatetime',
'change .o_datepicker_input': 'changeDatetime',
'input input': '_onInput',
+ 'keydown': '_onKeydown',
'show.datetimepicker': '_onDateTimePickerShow',
},
/**
@@ -240,6 +241,17 @@ var DateWidget = Widget.extend({
}
},
/**
+ * @private
+ * @param {KeyEvent} ev
+ */
+ _onKeydown: function (ev) {
+ if (ev.which === $.ui.keyCode.ESCAPE) {
+ this.__libInput++;
+ this.$el.datetimepicker('hide');
+ this.__libInput--;
+ }
+ },
+ /**
* Prevents 'input' events triggered by the library to bubble up, as they
* might have unwanted effects (like triggering 'field_changed' events in
* the context of field widgets)