Skip to content

Commit a98db66

Browse files
authored
fix(chat): hide profile hover card when username is clicked (#29444)
Clicking a hovered username navigates to the profile, but the pending debounced show (200ms) and DelayedMounting (300ms) timers were never cancelled, so the card could pop up on top of the profile page after navigation. Hide on mousedown on the anchor text; clicks inside the portaled card (follow/chat buttons) still work.
1 parent 167173a commit a98db66

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

shared/common-adapters/profile-card.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ export const WithProfileCardPopup = ({username, children, ellipsisStyle}: WithPr
302302
style={Styles.collapseStyles([styles.popupTextContainer, ellipsisStyle])}
303303
onMouseOver={onShow}
304304
onMouseLeave={onHide}
305+
onMouseDown={e => {
306+
// clicking the username navigates to the profile; cancel any pending/visible popup.
307+
// portal children bubble through the React tree, so only hide when the click is on
308+
// the anchor itself and not inside the floating card (follow/chat buttons).
309+
// loose typing since tsconfig.native compiles this file without DOM lib
310+
const anchor = e.currentTarget as unknown as {contains?: (t: unknown) => boolean}
311+
if (anchor.contains?.(e.target)) onHide()
312+
}}
305313
ref={popupAnchor}
306314
>
307315
{children()}

0 commit comments

Comments
 (0)