From 3275d19415634c055ee3aa43be8f05541a72f459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Geelen=20=28sge=29?= Date: Thu, 18 Nov 2021 14:33:58 +0000 Subject: [PATCH] [FIX] web_editor,website_sale: monetary field UX fix The forced selection of the entire text value was preventing the user from changing the selection after the initial click inside the monetary field. task-2679088 X-original-commit: d33d55aad46c9223192d15c01b7516340be77cce Part-of: odoo/odoo#80071 --- .../static/src/js/wysiwyg/wysiwyg.js | 26 ++++++++++++------- .../static/src/js/website_sale.editor.js | 19 -------------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 549782b76ee..bc69853252b 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -161,16 +161,22 @@ const Wysiwyg = Widget.extend({ }, 0); } } - if ($field.data('oe-type') === "monetary") { - $field.attr('contenteditable', false); - $field.find('.oe_currency_value').attr('contenteditable', true); - } - if ($field.data('oe-type') === "image") { - $field.attr('contenteditable', false); - $field.find('img').attr('contenteditable', true); - } - if ($field.is('[data-oe-many2one-id]')) { - $field.attr('contenteditable', false); + if ($field.attr('contenteditable') !== 'false') { + if ($field.data('oe-type') === "monetary") { + $field.attr('contenteditable', false); + const $currencyValue = $field.find('.oe_currency_value'); + $currencyValue.attr('contenteditable', true); + $currencyValue.one('mouseup touchend', (e) => { + $currencyValue.selectContent(); + }); + } + if ($field.data('oe-type') === "image") { + $field.attr('contenteditable', false); + $field.find('img').attr('contenteditable', true); + } + if ($field.is('[data-oe-many2one-id]')) { + $field.attr('contenteditable', false); + } } self.odooEditor.observerActive(); } diff --git a/addons/website_sale/static/src/js/website_sale.editor.js b/addons/website_sale/static/src/js/website_sale.editor.js index 231899f7883..ec45f046390 100644 --- a/addons/website_sale/static/src/js/website_sale.editor.js +++ b/addons/website_sale/static/src/js/website_sale.editor.js @@ -250,25 +250,6 @@ Wysiwyg.include({ }, }); -publicWidget.registry.websiteSaleCurrency = publicWidget.Widget.extend({ - selector: '.oe_website_sale', - disabledInEditableMode: false, - edit_events: { - 'click .oe_currency_value:o_editable': '_onCurrencyValueClick', - }, - - //-------------------------------------------------------------------------- - // Handlers - //-------------------------------------------------------------------------- - - /** - * @private - */ - _onCurrencyValueClick: function (ev) { - $(ev.currentTarget).selectContent(); - }, -}); - function reload() { if (window.location.href.match(/\?enable_editor/)) { window.location.reload();