Skip to content
Snippets Groups Projects
Commit 03c02639 authored by Benoit Socias's avatar Benoit Socias
Browse files

[IMP] web_editor: reset button text styles when customizing button

Before this commit if button text had styles, they would override the
color set by customizing the button.

After this commit button text styles are removed when applying custom
button colors.

task-2653874

Part-of: odoo/odoo#76936
parent 489e76ad
Branches
Tags
No related merge requests found
......@@ -258,6 +258,17 @@ const LinkTools = Link.extend({
this.colorpickers[cssProperty] = colorpicker;
colorpicker.appendTo($(ev.target).closest('.dropdown').find('.dropdown-menu'));
colorpicker.on('custom_color_picked color_picked color_hover color_leave', this, (ev) => {
// Reset color styles in link content to make sure new color is not hidden.
// Only done when applied to avoid losing state during preview.
if (['custom_color_picked', 'color_picked'].includes(ev.name)) {
const selection = window.getSelection();
const range = document.createRange();
range.selectNodeContents(this.$link[0]);
selection.removeAllRanges();
selection.addRange(range);
this.options.wysiwyg.odooEditor.execCommand('applyColor', '', 'color');
this.options.wysiwyg.odooEditor.execCommand('applyColor', '', 'backgroundColor');
}
let color = ev.data.color;
let gradientColor = '';
if (cssProperty === 'background-color') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment