From 0e041f2e77e66ffba89bf1ac8eae718cc55f30fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 6 Aug 2021 15:06:11 +0200 Subject: [PATCH] Fix clicking whitespaces on replies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/rooms/ReplyTile.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/ReplyTile.tsx b/src/components/views/rooms/ReplyTile.tsx index 16a7141bd7..8c0e09c76c 100644 --- a/src/components/views/rooms/ReplyTile.tsx +++ b/src/components/views/rooms/ReplyTile.tsx @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import React from 'react'; +import React, { createRef } from 'react'; import classNames from 'classnames'; import { _t } from '../../../languageHandler'; import dis from '../../../dispatcher/dispatcher'; @@ -38,6 +38,8 @@ interface IProps { @replaceableComponent("views.rooms.ReplyTile") export default class ReplyTile extends React.PureComponent { + private anchorElement = createRef(); + static defaultProps = { onHeightChanged: () => {}, }; @@ -71,7 +73,11 @@ export default class ReplyTile extends React.PureComponent { // 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 exception being the link wrapping the reply - if (clickTarget.tagName.toLowerCase() !== "a" || clickTarget.closest("a") === null) { + if ( + clickTarget.tagName.toLowerCase() !== "a" || + clickTarget.closest("a") === null || + clickTarget === this.anchorElement.current + ) { // 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(); @@ -141,7 +147,7 @@ export default class ReplyTile extends React.PureComponent { return (