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

Commit 40eb9ae

Browse files
authored
Merge pull request #6571 from SimonBrandner/fix/reply-whitespace/18327
Fix clicking whitespaces on replies
2 parents 2c601e0 + 0e041f2 commit 40eb9ae

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/components/views/rooms/ReplyTile.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React from 'react';
17+
import React, { createRef } from 'react';
1818
import classNames from 'classnames';
1919
import { _t } from '../../../languageHandler';
2020
import dis from '../../../dispatcher/dispatcher';
@@ -38,6 +38,8 @@ interface IProps {
3838

3939
@replaceableComponent("views.rooms.ReplyTile")
4040
export 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

Comments
 (0)