@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import React from 'react' ;
17+ import React , { createRef } from 'react' ;
1818import classNames from 'classnames' ;
1919import { _t } from '../../../languageHandler' ;
2020import dis from '../../../dispatcher/dispatcher' ;
@@ -38,6 +38,8 @@ interface IProps {
3838
3939@replaceableComponent ( "views.rooms.ReplyTile" )
4040export default class ReplyTile extends React . PureComponent < IProps > {
41+ private anchorElement = createRef < HTMLAnchorElement > ( ) ;
42+
4143 static defaultProps = {
4244 onHeightChanged : ( ) => { } ,
4345 } ;
@@ -71,7 +73,11 @@ export default class ReplyTile extends React.PureComponent<IProps> {
7173 // Following a link within a reply should not dispatch the `view_room` action
7274 // so that the browser can direct the user to the correct location
7375 // The exception being the link wrapping the reply
74- if ( clickTarget . tagName . toLowerCase ( ) !== "a" || clickTarget . closest ( "a" ) === null ) {
76+ if (
77+ clickTarget . tagName . toLowerCase ( ) !== "a" ||
78+ clickTarget . closest ( "a" ) === null ||
79+ clickTarget === this . anchorElement . current
80+ ) {
7581 // This allows the permalink to be opened in a new tab/window or copied as
7682 // matrix.to, but also for it to enable routing within Riot when clicked.
7783 e . preventDefault ( ) ;
@@ -141,7 +147,7 @@ export default class ReplyTile extends React.PureComponent<IProps> {
141147
142148 return (
143149 < div className = { classes } >
144- < a href = { permalink } onClick = { this . onClick } >
150+ < a href = { permalink } onClick = { this . onClick } ref = { this . anchorElement } >
145151 { sender }
146152 < EventTileType
147153 ref = "tile"
0 commit comments