From 0649134444fa6b26de1c8c25d7c4a3f70c6d64e0 Mon Sep 17 00:00:00 2001 From: "Mahdi Cheikh Rouhou (macr)" Date: Mon, 15 Jan 2024 16:08:26 +0100 Subject: [PATCH] [FIX] web_editor: Select hex in colorpicker Issue: ===== Clicking on hex color or rbga in colorpicker will reselect the inital selected text and not the value if hex or rgba. Steps to reproduce the issue: ============================= - Create a note , type anything and apply custom color - When clicking on the hex color code , the cursor is alwyas set back to the text. Origin of the issue: ==================== The behavior was introduced by https://github.com/odoo/odoo/commit/033b49e1a810c3decd8988698620616bd927f6c3 In the click listener, we always reset the comuted selection wich reselects the original text. When clicking on empty space on the dropdown menu, it happens too but it doesn't matter since the menu closes anyway, but clicking on text input fields that you want to update will be a problem since the menu doesn't close but the text get reselected. Solution: ========= To overcome the problem of resetting when clicking on the dropdown, we first check if the click is on the colorpicker or not, if Yes do nothing and skip this. task-3648629 closes odoo/odoo#155947 X-original-commit: 2c0a68df214f69b3d459507a6ce867620bf0513f Signed-off-by: Antoine Guenet (age) --- .../static/src/js/editor/odoo-editor/src/OdooEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index 4694668a7bc..e8606feb665 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -755,7 +755,7 @@ export class OdooEditor extends EventTarget { if (fontSizeInput && !fontSizeInput.readOnly && ev.target.closest('#font-size .dropdown-toggle')) { // If the click opened the font size dropdown, select the input content. fontSizeInput.select(); - } else if (!this.isSelectionInEditable()) { + } else if (!this.isSelectionInEditable() && ev.target.nodeName !== 'INPUT') { // Otherwise, if we lost the selection in the editable, restore it. this.historyResetLatestComputedSelection(true); }