From 97339ad0537f7ce1f57063279ad5b55ba92e6268 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Thu, 21 Jul 2022 20:51:00 +0200 Subject: [PATCH 1/3] Unbreak in-app permalink tooltips Fixes: vector-im/element-web#22874 Signed-off-by: Johannes Marbach --- src/utils/tooltipify.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/tooltipify.tsx b/src/utils/tooltipify.tsx index ec698aa198b..3af08ddf6f1 100644 --- a/src/utils/tooltipify.tsx +++ b/src/utils/tooltipify.tsx @@ -53,11 +53,11 @@ export function tooltipifyLinks(rootNodes: ArrayLike, ignoredNodes: Ele const href = node.getAttribute("href"); const tooltip = - + {node.innerHTML} ; ReactDOM.render(tooltip, container); - node.parentNode.replaceChild(container, node); + node.replaceChildren(container); containers.push(container); tooltipified = true; } From 6bf3499c6e6a61b77380c7c0f3e0a45a625aeadd Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Thu, 21 Jul 2022 21:01:00 +0200 Subject: [PATCH 2/3] Appease the linter --- src/utils/tooltipify.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/tooltipify.tsx b/src/utils/tooltipify.tsx index 3af08ddf6f1..3f7042e1575 100644 --- a/src/utils/tooltipify.tsx +++ b/src/utils/tooltipify.tsx @@ -53,7 +53,7 @@ export function tooltipifyLinks(rootNodes: ArrayLike, ignoredNodes: Ele const href = node.getAttribute("href"); const tooltip = - {node.innerHTML} + { node.innerHTML } ; ReactDOM.render(tooltip, container); From 5845969c60db2fd458947cfd37075939ae25ea3c Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Thu, 21 Jul 2022 21:15:27 +0200 Subject: [PATCH 3/3] Fix the tests --- test/utils/tooltipify-test.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/utils/tooltipify-test.tsx b/test/utils/tooltipify-test.tsx index b94c829faf3..468cd059e10 100644 --- a/test/utils/tooltipify-test.tsx +++ b/test/utils/tooltipify-test.tsx @@ -41,9 +41,10 @@ describe('tooltipify', () => { const containers: Element[] = []; tooltipifyLinks([root], [], containers); expect(containers).toHaveLength(1); - const anchor = root.querySelector(".mx_TextWithTooltip_target a"); + const anchor = root.querySelector("a"); expect(anchor?.getAttribute("href")).toEqual("/foo"); - expect(anchor?.innerHTML).toEqual("click"); + const tooltip = anchor.querySelector(".mx_TextWithTooltip_target"); + expect(tooltip).toBeDefined(); }); it('ignores node', () => {