summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-09-26 13:55:13 +0200
committerAaron Bohy <aab@odoo.com>2017-09-27 12:13:58 +0200
commit2d3e5711f1229c4be52e3f8553feb734fc3d1a44 (patch)
tree25efdfbc6d45d866694425d09df489171b08f3e0 /addons/web
parentdf04910d2af088a8bb2bd0ea9080494124b1753c (diff)
[FIX] web: escape pressed in editable list in dialog
should discard the edited row, but not close the dialog. Before this rev., it was closing the dialog.
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/static/src/js/fields/abstract_field.js2
-rw-r--r--addons/web/static/src/js/views/list/list_editable_renderer.js3
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js49
3 files changed, 52 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js
index 9b484354544..25aa9fceda9 100644
--- a/addons/web/static/src/js/fields/abstract_field.js
+++ b/addons/web/static/src/js/fields/abstract_field.js
@@ -444,7 +444,7 @@ var AbstractField = Widget.extend({
this.trigger_up('navigation_move', {direction: 'next_line'});
break;
case $.ui.keyCode.ESCAPE:
- this.trigger_up('navigation_move', {direction: 'cancel'});
+ this.trigger_up('navigation_move', {direction: 'cancel', originalEvent: ev});
break;
case $.ui.keyCode.UP:
ev.stopPropagation();
diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js
index 6519fdfaec4..1a2fe3bd624 100644
--- a/addons/web/static/src/js/views/list/list_editable_renderer.js
+++ b/addons/web/static/src/js/views/list/list_editable_renderer.js
@@ -661,6 +661,9 @@ ListRenderer.include({
this._moveToNextLine();
break;
case 'cancel':
+ // stop the original event (typically an ESCAPE keydown), to
+ // prevent from closing the potential dialog containing this list
+ ev.data.originalEvent.stopPropagation();
this.trigger_up('discard_changes', {
recordID: ev.target.dataPointID,
});
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index 75ee8e8bf3e..ab19f58a344 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -3204,6 +3204,54 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('pressing escape in editable o2m list in dialog', function (assert) {
+ assert.expect(3);
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<group>' +
+ '<field name="p">' +
+ '<tree>' +
+ '<field name="display_name"/>' +
+ '</tree>' +
+ '</field>' +
+ '</group>' +
+ '</form>',
+ res_id: 1,
+ archs: {
+ "partner,false,form": '<form>' +
+ '<field name="p">' +
+ '<tree editable="bottom">' +
+ '<field name="display_name"/>' +
+ '</tree>' +
+ '</field>' +
+ '</form>',
+ },
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ form.$('.o_field_x2many_list_row_add a').click();
+ $('.modal .o_field_x2many_list_row_add a').click();
+
+ assert.strictEqual($('.modal .o_data_row.o_selected_row').length, 1,
+ "there should be a row in edition in the dialog");
+
+ // trigger keydown ESCAPE in the edited row
+ $('.modal .o_data_cell input').trigger({type: 'keydown', which: $.ui.keyCode.ESCAPE});
+
+ assert.strictEqual($('.modal').length, 1,
+ "dialog should still be open");
+ assert.strictEqual($('.modal .o_data_row').length, 0,
+ "the row should have been removed");
+
+ form.destroy();
+ });
+
QUnit.test('editable o2m with onchange and required field: delete an invalid line', function (assert) {
assert.expect(5);
@@ -5586,7 +5634,6 @@ QUnit.module('relational_fields', {
form.destroy();
});
-
QUnit.test('editing tabbed one2many (editable=bottom)', function (assert) {
assert.expect(11);