From 5d00383d710c267bac30a89fc122825af36cc707 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Wed, 5 Mar 2025 13:23:28 +1100 Subject: [PATCH] fix crash on emoji selection from emojiboard (#2249) * fix crash on emoji select * fix crash in message editor on emoji select --- src/app/features/room/RoomInput.tsx | 9 +++++++-- src/app/features/room/message/MessageEditor.tsx | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 97f80595..eb214f62 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -600,8 +600,13 @@ export const RoomInput = forwardRef( onCustomEmojiSelect={handleEmoticonSelect} onStickerSelect={handleStickerSelect} requestClose={() => { - setEmojiBoardTab(undefined); - if (!mobileOrTablet()) ReactEditor.focus(editor); + setEmojiBoardTab((t) => { + if (t) { + if (!mobileOrTablet()) ReactEditor.focus(editor); + return undefined; + } + return t; + }); }} /> } diff --git a/src/app/features/room/message/MessageEditor.tsx b/src/app/features/room/message/MessageEditor.tsx index dc59dcdf..ac97e2aa 100644 --- a/src/app/features/room/message/MessageEditor.tsx +++ b/src/app/features/room/message/MessageEditor.tsx @@ -305,8 +305,13 @@ export const MessageEditor = as<'div', MessageEditorProps>( onEmojiSelect={handleEmoticonSelect} onCustomEmojiSelect={handleEmoticonSelect} requestClose={() => { - setAnchor(undefined); - if (!mobileOrTablet()) ReactEditor.focus(editor); + setAnchor((v) => { + if (v) { + if (!mobileOrTablet()) ReactEditor.focus(editor); + return undefined; + } + return v; + }); }} /> }