[FIX] website: stop losing whitespaces around social medias

During edit mode, editing the social media snippet induced losing the
whitespaces between the social media icons, thus reducing the space
between them. That space was however restored after saving.

After this commit, after each social media snippet change, we restore
a line break whitespace between each social media icon.

task-2739937

closes odoo/odoo#87933

X-original-commit: 3b8f11273bfa926172a4297785e58dfea92728d9
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2022-04-05 10:54:10 +02:00
parent 6ee1c526a7
commit 9a4fa79bac
@@ -155,6 +155,17 @@ options.registry.SocialMedia = options.Class.extend({
// Place the link at the correct position
this.$target[0].appendChild(anchorEl);
}
// Restore whitespaces around the links
this.$target[0].normalize();
const finalLinkEls = this.$target[0].querySelectorAll(':scope > a');
if (finalLinkEls.length) {
finalLinkEls[0].previousSibling.textContent = '\n';
for (const linkEl of finalLinkEls) {
linkEl.after(document.createTextNode('\n'));
}
}
this._handleNoMediaAlert();
},