[REV] web_editor: not add a zero-width space on top of color palettes

Since [1] a zero-width space is added inside all `we-selection-items`.
This breaks the layout of color palettes because zero-width spaces
still have a height, and are not considered as empty text.

This reverts commit e59ad49cb9f32240d8ca3c89fc20ab200e291adc.

based on:

https://github.com/odoo/odoo/pull/97382#issuecomment-1208015098

[1]: https://github.com/odoo/odoo/commit/e59ad49cb9f32240d8ca3c89fc20ab200e291adc

task-2919573

closes odoo/odoo#97829

X-original-commit: 2091bce403368003add4b01eaafaea051c758e27
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Benoit Socias
2022-08-10 09:21:19 +02:00
parent 696f4dc753
commit 19e4f1a856
@@ -253,7 +253,6 @@ const UserValueWidget = Widget.extend({
this.containerEl = document.createElement('div');
if (this.imgEl) {
this.containerEl.appendChild(document.createTextNode('\u200B')); // Ensures proper vertical centering.
this.containerEl.appendChild(this.imgEl);
}
@@ -856,14 +855,7 @@ const BaseSelectionUserValueWidget = UserValueWidget.extend({
this.menuEl = document.createElement('we-selection-items');
if (this.options && this.options.childNodes) {
this.options.childNodes.forEach(node => {
if (node) {
if (node.nodeType === Node.ELEMENT_NODE) {
node.insertBefore(document.createTextNode('\u200B'), node.firstChild); // Ensures proper height.
}
this.menuEl.appendChild(node);
}
});
this.options.childNodes.forEach(node => node && this.menuEl.appendChild(node));
}
this.containerEl.appendChild(this.menuEl);
},
@@ -952,7 +944,6 @@ const SelectUserValueWidget = BaseSelectionUserValueWidget.extend({
}
this.menuTogglerEl = document.createElement('we-toggler');
this.menuTogglerEl.appendChild(document.createTextNode('\u200B')); // Ensures proper height.
this.iconEl = this.imgEl || null;
const icon = this.el.dataset.icon;
if (icon) {
@@ -1011,11 +1002,11 @@ const SelectUserValueWidget = BaseSelectionUserValueWidget.extend({
this.menuTogglerItemEl = null;
}
let textContent = '\u200B'; // Ensures proper height.
let textContent = '';
const activeWidget = this._userValueWidgets.find(widget => !widget.isPreviewed() && widget.isActive());
if (activeWidget) {
const svgTag = activeWidget.el.querySelector('svg'); // useful to avoid searching text content in svg element
const value = (activeWidget.el.dataset.selectLabel || (!svgTag && activeWidget.el.textContent.replace('\u200B', '').trim()));
const value = (activeWidget.el.dataset.selectLabel || (!svgTag && activeWidget.el.textContent.trim()));
const imgSrc = activeWidget.el.dataset.img;
if (value) {
textContent = value;