Skip to content

Commit

Permalink
Unbreak URL preview for formatted links with tooltips
Browse files Browse the repository at this point in the history
Fixes: element-hq/element-web#22764
Signed-off-by: Johannes Marbach <johannesm@element.io>
  • Loading branch information
Johennes committed Jul 8, 2022
1 parent 4844cc1 commit fe33519
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/BasePlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/components/views/messages/TextualBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
// 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");
Expand Down

0 comments on commit fe33519

Please sign in to comment.