[FIX] web_editor: properly detect background color in toolbar
When a background color is applied on an ancestor, while it's visibly there, `getComputedStyle` doesn't know. Because it did depend on it, the toolbar showed the wrong color in these cases. Eg: `<span style="background-color: red;"><b>a[]bc</b></span>` was showing no background color. task-2778416 X-original-commit: a125933b34500d51183bc5eb02a531fb3b293de5 Part-of: odoo/odoo#86930
This commit is contained in:
@@ -1445,7 +1445,14 @@ export class OdooEditor extends EventTarget {
|
||||
if (hasGradient && !hasTextGradientClass) {
|
||||
hiliteColor = backgroundImage;
|
||||
} else {
|
||||
hiliteColor = computedStyle.backgroundColor;
|
||||
let ancestor = endContainer;
|
||||
while (ancestor && !hiliteColor) {
|
||||
hiliteColor = ancestor.style.backgroundColor;
|
||||
ancestor = ancestor.parentElement;
|
||||
}
|
||||
if (!hiliteColor) {
|
||||
hiliteColor = computedStyle.backgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user