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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user