From 2015b1a0d9739c08b4b33b0ef96a761f7a66d00d Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 20 Aug 2021 23:47:24 +0300 Subject: [PATCH] Message Input: Focus after clsing Attachment Modal --- src/components/middle/composer/AttachmentModal.tsx | 2 +- src/components/middle/composer/Composer.tsx | 2 +- src/components/middle/composer/MessageInput.tsx | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/middle/composer/AttachmentModal.tsx b/src/components/middle/composer/AttachmentModal.tsx index 4a439e8c..117612c2 100644 --- a/src/components/middle/composer/AttachmentModal.tsx +++ b/src/components/middle/composer/AttachmentModal.tsx @@ -244,7 +244,7 @@ const AttachmentModal: FC = ({ placeholder={lang('Caption')} onUpdate={onCaptionUpdate} onSend={onSend} - shouldSetFocus={isOpen} + shouldSetFocus={Boolean(attachments.length)} /> diff --git a/src/components/middle/composer/Composer.tsx b/src/components/middle/composer/Composer.tsx index 3ab3d8c6..f1a16dbe 100644 --- a/src/components/middle/composer/Composer.tsx +++ b/src/components/middle/composer/Composer.tsx @@ -919,7 +919,7 @@ const Composer: FC = ({ : botKeyboardPlaceholder || lang('Message') } forcedPlaceholder={inlineBotHelp} - shouldSetFocus={isSymbolMenuOpen} + shouldSetFocus={!attachments.length} shouldSuppressFocus={IS_SINGLE_COLUMN_LAYOUT && isSymbolMenuOpen} shouldSuppressTextFormatter={isEmojiTooltipOpen || isMentionTooltipOpen || isInlineBotTooltipOpen} onUpdate={setHtml} diff --git a/src/components/middle/composer/MessageInput.tsx b/src/components/middle/composer/MessageInput.tsx index dcfab0ca..6bbb5396 100644 --- a/src/components/middle/composer/MessageInput.tsx +++ b/src/components/middle/composer/MessageInput.tsx @@ -329,7 +329,9 @@ const MessageInput: FC = ({ return; } - focusInput(); + if (shouldSetFocus) { + focusInput(); + } }, [currentChatId, focusInput, replyingToId, shouldSetFocus]); useEffect(() => {