From 19e4f1a85654efe275d8bb166b28eb6a32c36d93 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Tue, 9 Aug 2022 06:54:07 +0000 Subject: [PATCH] [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) --- .../static/src/js/editor/snippets.options.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index fe9ccaccffb..e861a31b847 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -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;