Fixes around URL tooltips and in-app matrix.to link handling (#9139)
* Add regression test for tooltipify exposing raw HTML * Handle m.to links involving children better * Comments * Fix mistaken assertion
This commit is contained in:
parent
48ae16b5a5
commit
e63072e21f
4 changed files with 37 additions and 19 deletions
|
@ -432,11 +432,17 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
|
|||
* to start with (e.g. pills, links in the content).
|
||||
*/
|
||||
private onBodyLinkClick = (e: MouseEvent): void => {
|
||||
const target = e.target as Element;
|
||||
if (target.nodeName !== "A" || target.classList.contains(linkifyOpts.className)) return;
|
||||
const { href } = target as HTMLLinkElement;
|
||||
const localHref = tryTransformPermalinkToLocalHref(href);
|
||||
if (localHref !== href) {
|
||||
let target = e.target as HTMLLinkElement;
|
||||
// links processed by linkifyjs have their own handler so don't handle those here
|
||||
if (target.classList.contains(linkifyOpts.className)) return;
|
||||
if (target.nodeName !== "A") {
|
||||
// Jump to parent as the `<a>` may contain children, e.g. an anchor wrapping an inline code section
|
||||
target = target.closest<HTMLLinkElement>("a");
|
||||
}
|
||||
if (!target) return;
|
||||
|
||||
const localHref = tryTransformPermalinkToLocalHref(target.href);
|
||||
if (localHref !== target.href) {
|
||||
// it could be converted to a localHref -> therefore handle locally
|
||||
e.preventDefault();
|
||||
window.location.hash = localHref;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue