From 30ce7b5eabc1e158de16f260c4eb41b18c188333 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Tue, 27 Jul 2021 17:57:46 +0200 Subject: [PATCH 1/2] Make link within replies clickable --- src/components/views/rooms/ReplyTile.tsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/views/rooms/ReplyTile.tsx b/src/components/views/rooms/ReplyTile.tsx index 18b30d33d5..e06cc90817 100644 --- a/src/components/views/rooms/ReplyTile.tsx +++ b/src/components/views/rooms/ReplyTile.tsx @@ -67,15 +67,21 @@ export default class ReplyTile extends React.PureComponent { }; private onClick = (e: React.MouseEvent): void => { - // This allows the permalink to be opened in a new tab/window or copied as - // matrix.to, but also for it to enable routing within Riot when clicked. - e.preventDefault(); - dis.dispatch({ - action: 'view_room', - event_id: this.props.mxEvent.getId(), - highlighted: true, - room_id: this.props.mxEvent.getRoomId(), - }); + const clickTarget = e.target as HTMLElement; + // Following a link within a reply should not dispatch the `view_room` action + // so that the browser can direct the user to the correct location + // The exceptionp being the link wrapping the reply + if (clickTarget.tagName.toLowerCase() !== "a" || clickTarget.closest("a") === null) { + // This allows the permalink to be opened in a new tab/window or copied as + // matrix.to, but also for it to enable routing within Riot when clicked. + e.preventDefault(); + dis.dispatch({ + action: 'view_room', + event_id: this.props.mxEvent.getId(), + highlighted: true, + room_id: this.props.mxEvent.getRoomId(), + }); + } }; render() { From 7e453d77450aa369618f32c1f072e19322c2e244 Mon Sep 17 00:00:00 2001 From: Germain Date: Tue, 27 Jul 2021 17:14:39 +0100 Subject: [PATCH 2/2] Typo Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/ReplyTile.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/rooms/ReplyTile.tsx b/src/components/views/rooms/ReplyTile.tsx index e06cc90817..16a7141bd7 100644 --- a/src/components/views/rooms/ReplyTile.tsx +++ b/src/components/views/rooms/ReplyTile.tsx @@ -70,7 +70,7 @@ export default class ReplyTile extends React.PureComponent { const clickTarget = e.target as HTMLElement; // Following a link within a reply should not dispatch the `view_room` action // so that the browser can direct the user to the correct location - // The exceptionp being the link wrapping the reply + // The exception being the link wrapping the reply if (clickTarget.tagName.toLowerCase() !== "a" || clickTarget.closest("a") === null) { // This allows the permalink to be opened in a new tab/window or copied as // matrix.to, but also for it to enable routing within Riot when clicked.