From 26b29de7d2274ecb3796def2e99c3b32e3a994d5 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 22 Mar 2021 12:21:47 +0000 Subject: [PATCH] [FIX] web_editor: no quick edit on html link click When clicking on link in html fields, we do not wish to start quick edition. With this change this is excluded. closes #68023 closes odoo/odoo#68212 X-original-commit: ecbdddbf0cff0964b44e7f0571d372ccbd051a72 Related: odoo/enterprise#17235 Signed-off-by: Nicolas Lempereur (nle) Signed-off-by: Aaron Bohy (aab) --- .../static/src/js/backend/field_html.js | 3 ++ .../static/tests/field_html_tests.js | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/addons/web_editor/static/src/js/backend/field_html.js b/addons/web_editor/static/src/js/backend/field_html.js index f311079f43d..16d1b602575 100644 --- a/addons/web_editor/static/src/js/backend/field_html.js +++ b/addons/web_editor/static/src/js/backend/field_html.js @@ -35,6 +35,9 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { className: 'oe_form_field oe_form_field_html', supportedFieldTypes: ['html'], isQuickEditable: true, + quickEditExclusion: [ + '[href]', + ], custom_events: { wysiwyg_focus: '_onWysiwygFocus', diff --git a/addons/web_editor/static/tests/field_html_tests.js b/addons/web_editor/static/tests/field_html_tests.js index 78ae590495e..bb8e509a054 100644 --- a/addons/web_editor/static/tests/field_html_tests.js +++ b/addons/web_editor/static/tests/field_html_tests.js @@ -2,6 +2,7 @@ odoo.define('web_editor.field_html_tests', function (require) { "use strict"; var ajax = require('web.ajax'); +var FormController = require('web.FormController'); var FormView = require('web.FormView'); var testUtils = require('web.test_utils'); var weTestUtils = require('web_editor.test_utils'); @@ -120,9 +121,13 @@ QUnit.module('web_editor', {}, function () { throw 'Wrong template'; }, }); + testUtils.mock.patch(FormController, { + 'multiClickTime': 0, + }); }, afterEach: function () { testUtils.mock.unpatch(ajax); + testUtils.mock.unpatch(FormController); }, }, function () { @@ -644,6 +649,34 @@ QUnit.module('web_editor', {}, function () { form.destroy(); }); + QUnit.test('Quick Edition: click on link inside html field', async function (assert) { + assert.expect(3); + + this.data['note.note'].records[0]['body'] = '

hello world

'; + + const form = await testUtils.createView({ + View: FormView, + model: 'note.note', + data: this.data, + arch: '
' + + '' + + '', + res_id: 1, + }); + + assert.containsOnce(form, '.o_form_view.o_form_readonly'); + + await testUtils.dom.click(form.$('.oe_form_field[name="body"] a')); + await testUtils.nextTick(); + assert.containsOnce(form, '.o_form_view.o_form_readonly'); + + await testUtils.dom.click(form.$('.oe_form_field[name="body"] p')); + await testUtils.nextTick(); + assert.containsOnce(form, '.o_form_view.o_form_editable'); + + form.destroy(); + }); + QUnit.module('cssReadonly'); QUnit.test('rendering with iframe for readonly mode', async function (assert) {