[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) <age@odoo.com>
This commit is contained in:
Mahdi Cheikh Rouhou (macr)
2024-03-01 08:45:46 +00:00
parent da5136dc8a
commit 0649134444
@@ -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);
}