fix: capture emoji button rect before state updater to avoid null currentTarget

React nullifies synthetic event's currentTarget before async state
updater callbacks run. Capture getBoundingClientRect() synchronously
in the onClick handler, then pass the already-computed rect into
setEmojiAnchor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 13:06:31 -04:00
parent 46da4458ff
commit e280f0e312
@@ -436,11 +436,10 @@ function ProfileStatus() {
aria-label="Insert emoji"
aria-expanded={!!emojiAnchor}
aria-haspopup="dialog"
onClick={(evt: React.MouseEvent<HTMLButtonElement>) =>
setEmojiAnchor((prev) =>
prev ? undefined : evt.currentTarget.getBoundingClientRect(),
)
}
onClick={(evt: React.MouseEvent<HTMLButtonElement>) => {
const rect = evt.currentTarget.getBoundingClientRect();
setEmojiAnchor((prev) => (prev ? undefined : rect));
}}
>
<Icon src={Icons.Smile} size="100" />
</IconButton>