[FIX] web_editor: properly mark duplicated color buttons as selected

Since [1], the colorpalette widget's layout was updated such that some
colors now appear multiple times in some circumstances (e.g. the grays
appears in custom tab and theme tab). Since then, asking to mark one of
those color as selected, only marked the first one as such, and that
first one may be in an hidden panel. This commit fixes the issues by
marking them all as selected, as it should. This changes what is
explained in [2] too.

[1]: https://github.com/odoo/odoo/commit/96ab729850983162a0039e40c77537ef65cd039e
[2]: https://github.com/odoo/odoo/commit/508a7f980652172a7ed00da43f6bc3bc586089fe

Part of https://github.com/odoo/odoo/pull/73611
task-2599770
This commit is contained in:
qsm-odoo
2021-08-17 16:38:13 +00:00
parent d63674d989
commit c61ae75874
@@ -359,9 +359,9 @@ const ColorPaletteWidget = Widget.extend({
*/
_markSelectedColor: function () {
this.el.querySelectorAll('button.selected').forEach(el => el.classList.remove('selected'));
const selectedButton = this.el.querySelector(`button[data-color="${this.selectedColor}"], button[style*="background-color:${this.selectedColor};"]`);
if (selectedButton) {
selectedButton.classList.add('selected');
const buttonToSelectEls = this.el.querySelectorAll(`button[data-color="${this.selectedColor}"], button[style*="background-color:${this.selectedColor};"]`);
for (const buttonToSelectEl of buttonToSelectEls) {
buttonToSelectEl.classList.add('selected');
}
},
/**