From fe33519fcb0fa7ca580cad2f6d17380943218e06 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 8 Jul 2022 10:56:30 +0200 Subject: [PATCH 1/2] Unbreak URL preview for formatted links with tooltips Fixes: vector-im/element-web#22764 Signed-off-by: Johannes Marbach --- src/BasePlatform.ts | 2 +- src/components/views/messages/TextualBody.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index 232b44d7c96..44d802139c0 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -236,7 +236,7 @@ export default abstract class BasePlatform { * @returns {boolean} whether the platform requires URL previews in tooltips */ public needsUrlTooltips(): boolean { - return false; + return true; } /** diff --git a/src/components/views/messages/TextualBody.tsx b/src/components/views/messages/TextualBody.tsx index 39334e9d465..ce58886c88e 100644 --- a/src/components/views/messages/TextualBody.tsx +++ b/src/components/views/messages/TextualBody.tsx @@ -93,9 +93,14 @@ export default class TextualBody extends React.Component { // we should be pillify them here by doing the linkifying BEFORE the pillifying. pillifyLinks([this.contentRef.current], this.props.mxEvent, this.pills); HtmlUtils.linkifyElement(this.contentRef.current); - tooltipifyLinks([this.contentRef.current], this.pills, this.tooltips); + this.calculateUrlPreview(); + // tooltipifyLinks AFTER calculateUrlPreview because the DOM inside the tooltip + // container is empty before the internal component has mounted so calculateUrlPreview + // won't find any anchors + tooltipifyLinks([this.contentRef.current], this.pills, this.tooltips); + if (this.props.mxEvent.getContent().format === "org.matrix.custom.html") { // Handle expansion and add buttons const pres = (ReactDOM.findDOMNode(this) as Element).getElementsByTagName("pre"); From cbd41ee1742c27f7d3139f467a6360f1aa78d9b0 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 8 Jul 2022 11:33:12 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Flip=20back=20the=20flag=20default=20value?= =?UTF-8?q?=20=F0=9F=A4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BasePlatform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index 44d802139c0..232b44d7c96 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -236,7 +236,7 @@ export default abstract class BasePlatform { * @returns {boolean} whether the platform requires URL previews in tooltips */ public needsUrlTooltips(): boolean { - return true; + return false; } /**