[FIX] web_editor: properly toggle active link button

The link button was toggling its active state on every update of the
toolbar because we weren't passing the toggle function a boolean. and
if the element we were passing it was `undefined`, it triggered the
default behavior which is to just toggle. Instead we want it to be false
if the element is `undefined`.

X-original-commit: 7aecd36a169033a89defeb00ba0ae53cd64cdcd5
Part-of: odoo/odoo#86930
This commit is contained in:
Antoine Guenet
2022-03-22 22:12:55 +01:00
parent ab37804400
commit 0f1071d309
@@ -2009,7 +2009,7 @@ export class OdooEditor extends EventTarget {
const linkNode = getInSelection(this.document, 'a');
const linkButton = this.toolbar.querySelector('#createLink');
linkButton && linkButton.classList.toggle('active', linkNode);
linkButton && linkButton.classList.toggle('active', !!linkNode);
const unlinkButton = this.toolbar.querySelector('#unlink');
unlinkButton && unlinkButton.classList.toggle('d-none', !linkNode);
const undoButton = this.toolbar.querySelector('#undo');