From a62be22cb16c63eb00e10aaa4190492d05c4ad45 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 11 Nov 2024 16:11:24 +0100 Subject: [PATCH] Fix clicking on avatar/display opening status instead of profile (#2897) Fix regression from #2895 --- .../flavours/glitch/components/status.jsx | 41 ++++++++++--------- .../glitch/components/status_header.jsx | 11 ++--- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/app/javascript/flavours/glitch/components/status.jsx b/app/javascript/flavours/glitch/components/status.jsx index 7e2da0d4c7..a8da05171e 100644 --- a/app/javascript/flavours/glitch/components/status.jsx +++ b/app/javascript/flavours/glitch/components/status.jsx @@ -372,26 +372,29 @@ class Status extends ImmutablePureComponent { const { isCollapsed } = this.state; if (!history) return; - if (e.button === 0 && !(e.ctrlKey || e.altKey || e.metaKey)) { - if (isCollapsed) this.setCollapsed(false); - else if (e.shiftKey) { - this.setCollapsed(true); - document.getSelection().removeAllRanges(); - } else if (this.props.onClick) { - this.props.onClick(); - return; - } else { - if (destination === undefined) { - destination = `/@${ - status.getIn(['reblog', 'account', 'acct'], status.getIn(['account', 'acct'])) - }/${ - status.getIn(['reblog', 'id'], status.get('id')) - }`; - } - history.push(destination); - } - e.preventDefault(); + if (e.button !== 0 || e.ctrlKey || e.altKey || e.metaKey) { + return; } + + if (isCollapsed) this.setCollapsed(false); + else if (e.shiftKey) { + this.setCollapsed(true); + document.getSelection().removeAllRanges(); + } else if (this.props.onClick) { + this.props.onClick(); + return; + } else { + if (destination === undefined) { + destination = `/@${ + status.getIn(['reblog', 'account', 'acct'], status.getIn(['account', 'acct'])) + }/${ + status.getIn(['reblog', 'id'], status.get('id')) + }`; + } + history.push(destination); + } + + e.preventDefault(); }; handleToggleMediaVisibility = () => { diff --git a/app/javascript/flavours/glitch/components/status_header.jsx b/app/javascript/flavours/glitch/components/status_header.jsx index 5eeed3d41d..dffffe4fb8 100644 --- a/app/javascript/flavours/glitch/components/status_header.jsx +++ b/app/javascript/flavours/glitch/components/status_header.jsx @@ -18,15 +18,10 @@ export default class StatusHeader extends PureComponent { parseClick: PropTypes.func.isRequired, }; - // Handles clicks on account name/image - handleClick = (acct, e) => { - const { parseClick } = this.props; - parseClick(e, `/@${acct}`); - }; - handleAccountClick = (e) => { - const { status } = this.props; - this.handleClick(status.getIn(['account', 'acct']), e); + const { status, parseClick } = this.props; + parseClick(e, `/@${status.getIn(['account', 'acct'])}`); + e.stopPropagation(); }; // Rendering.