fix(app): auto focus Textarea when attaching files (#1238)

This commit is contained in:
Mizarc authored and GitHub committed 2026-07-01 07:38:41 +02:00
1 parent e49f16e307
commit 3a68f1787d
2 files changed
+8 -1

No files matched your search

@@ -575,6 +575,10 @@ const ChannelTextareaContent = observer(
<TooManyAttachmentsModal data-flx="channel.channel-textarea.handle-file-button-click.too-many-attachments-modal" /> <TooManyAttachmentsModal data-flx="channel.channel-textarea.handle-file-button-click.too-many-attachments-modal" />
)), )),
); );
return;
}
if (files.length > 0) {
textareaRef.current?.focus();
} }
}, [canAttachFiles, channel.id, textareaInputDisabled, maxAttachments, uploadAttachments.length]); }, [canAttachFiles, channel.id, textareaInputDisabled, maxAttachments, uploadAttachments.length]);
const handleUploadMessageAsFile = useCallback(async () => { const handleUploadMessageAsFile = useCallback(async () => {
@@ -599,6 +603,7 @@ const ChannelTextareaContent = observer(
} }
setValue(''); setValue('');
DraftCommands.deleteDraft(channel.id); DraftCommands.deleteDraft(channel.id);
textareaRef.current?.focus();
}, [textareaInputDisabled, canAttachFiles, value, channel.id, uploadAttachments.length, maxAttachments]); }, [textareaInputDisabled, canAttachFiles, value, channel.id, uploadAttachments.length, maxAttachments]);
useTextareaExpressionHandlers({ useTextareaExpressionHandlers({
setValue, setValue,
@@ -49,7 +49,9 @@ export const UploadManager = observer(({channel, canAttachFiles, canSendMessages
ModalCommands.popWithKey(UPLOAD_DROP_MODAL_KEY); ModalCommands.popWithKey(UPLOAD_DROP_MODAL_KEY);
}, []); }, []);
const focusTextarea = useCallback(() => { const focusTextarea = useCallback(() => {
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId: channel.id}); setTimeout(() => {
ComponentDispatch.dispatch('FOCUS_TEXTAREA', {channelId: channel.id});
}, 0);
}, [channel.id]); }, [channel.id]);
const onDrop = useCallback( const onDrop = useCallback(
async (files: Array<File>, directUpload = false) => { async (files: Array<File>, directUpload = false) => {