From cc64e8eaceaa7b1c707af168afd6e7046a730bb7 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 8 Jul 2022 11:51:37 +0200 Subject: [PATCH] Unbreak URL preview for formatted links with tooltips (#9022) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Unbreak URL preview for formatted links with tooltips Fixes: vector-im/element-web#22764 Signed-off-by: Johannes Marbach * Flip back the flag default value 🤦 --- src/components/views/messages/TextualBody.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/views/messages/TextualBody.tsx b/src/components/views/messages/TextualBody.tsx index 39334e9d46..ce58886c88 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");