Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Unbreak in-app permalink tooltips #9100

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/utils/tooltipify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export function tooltipifyLinks(rootNodes: ArrayLike<Element>, ignoredNodes: Ele
const href = node.getAttribute("href");

const tooltip = <LinkWithTooltip tooltip={new URL(href, window.location.href).toString()}>
<span dangerouslySetInnerHTML={{ __html: node.outerHTML }} />
{ node.innerHTML }
</LinkWithTooltip>;

ReactDOM.render(tooltip, container);
node.parentNode.replaceChild(container, node);
node.replaceChildren(container);
containers.push(container);
tooltipified = true;
}
Expand Down
5 changes: 3 additions & 2 deletions test/utils/tooltipify-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down