From 182643d741c183efa3249ecf35d46de0399ea5c6 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 5 Feb 2026 10:43:17 -0600 Subject: [PATCH] Fix autofocus --- src/view/com/composer/Composer.tsx | 2 +- src/view/com/composer/text-input/TextInput.tsx | 2 +- src/view/com/composer/text-input/TextInput.web.tsx | 13 ++----------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 50e9122233..425440609b 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -1320,7 +1320,7 @@ let ComposerPost = React.memo(function ComposerPost({ style={[a.pt_xs]} richtext={richtext} placeholder={selectTextInputPlaceholder} - autoFocus + autoFocus={isLastPost} webForceMinHeight={forceMinHeight} // To avoid overlap with the close button: hasRightPadding={isPartOfThread} diff --git a/src/view/com/composer/text-input/TextInput.tsx b/src/view/com/composer/text-input/TextInput.tsx index f9f50497f8..4cc11f5967 100644 --- a/src/view/com/composer/text-input/TextInput.tsx +++ b/src/view/com/composer/text-input/TextInput.tsx @@ -226,7 +226,7 @@ export function TextInput({ placeholder={placeholder} placeholderTextColor={t.atoms.text_contrast_medium.color} keyboardAppearance={theme.colorScheme} - autoFocus={true} + autoFocus={props.autoFocus !== undefined ? props.autoFocus : true} allowFontScaling multiline scrollEnabled={false} diff --git a/src/view/com/composer/text-input/TextInput.web.tsx b/src/view/com/composer/text-input/TextInput.web.tsx index a087a3d69b..3068c8f9df 100644 --- a/src/view/com/composer/text-input/TextInput.web.tsx +++ b/src/view/com/composer/text-input/TextInput.web.tsx @@ -52,6 +52,7 @@ export function TextInput({ onPressPublish, onNewLink, onFocus, + autoFocus, }: TextInputProps) { const {theme: t, fonts} = useAlf() const autocomplete = useActorAutocompleteFn() @@ -244,20 +245,10 @@ export function TextInput({ content: generateJSON(richTextToHTML(richtext), extensions, { preserveWhitespace: 'full', }), - autofocus: 'end', + autofocus: autoFocus ? 'end' : null, editable: true, injectCSS: true, shouldRerenderOnTransaction: false, - onCreate({editor: editorProp}) { - // HACK - // the 'enter' animation sometimes causes autofocus to fail - // (see Composer.web.tsx in shell) - // so we wait 200ms (the anim is 150ms) and then focus manually - // -prf - setTimeout(() => { - editorProp.chain().focus('end').run() - }, 200) - }, onUpdate({editor: editorProp}) { const json = editorProp.getJSON() const newText = editorJsonToText(json)