[FIX] web_editor: page crash on colour selection
Before this commit: When we select text and take the selection to the hex input box and then try again to add a solid color, it gives us a traceback. After this commit: Now it did not give traceback. Task-2965091 closes odoo/odoo#116539 X-original-commit: 981713bd024a98f5d9099bfec8458224dac32a32 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -1767,14 +1767,14 @@ const Wysiwyg = Widget.extend({
|
||||
}
|
||||
const coloredElements = this.odooEditor.execCommand('applyColor', color, eventName === 'foreColor' ? 'color' : 'backgroundColor', this.lastMediaClicked);
|
||||
|
||||
const coloredTds = coloredElements.filter(coloredElement => coloredElement.classList.contains('o_selected_td'));
|
||||
const coloredTds = coloredElements && coloredElements.length && coloredElements.filter(coloredElement => coloredElement.classList.contains('o_selected_td'));
|
||||
if (coloredTds.length) {
|
||||
const propName = eventName === 'foreColor' ? 'color' : 'background-color';
|
||||
for (const td of coloredTds) {
|
||||
// Make it important so it has priority over selection color.
|
||||
td.style.setProperty(propName, td.style[propName], previewMode ? 'important' : '');
|
||||
}
|
||||
} else if (!this.lastMediaClicked) {
|
||||
} else if (!this.lastMediaClicked && coloredElements && coloredElements.length) {
|
||||
// Ensure the selection in the fonts tags, otherwise an undetermined
|
||||
// race condition could generate a wrong selection later.
|
||||
const first = coloredElements[0];
|
||||
|
||||
Reference in New Issue
Block a user