From 0f1071d30980f221460f019f15cb4d03bcf33089 Mon Sep 17 00:00:00 2001
From: Antoine Guenet <age@odoo.com>
Date: Fri, 11 Mar 2022 11:23:35 +0000
Subject: [PATCH] [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
---
 addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js
index e1d63b184278..9eb0a0ac5655 100644
--- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js
+++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js
@@ -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');
-- 
GitLab