Fix autofocus
This commit is contained in:
@@ -1320,7 +1320,7 @@ let ComposerPost = React.memo(function ComposerPost({
|
|||||||
style={[a.pt_xs]}
|
style={[a.pt_xs]}
|
||||||
richtext={richtext}
|
richtext={richtext}
|
||||||
placeholder={selectTextInputPlaceholder}
|
placeholder={selectTextInputPlaceholder}
|
||||||
autoFocus
|
autoFocus={isLastPost}
|
||||||
webForceMinHeight={forceMinHeight}
|
webForceMinHeight={forceMinHeight}
|
||||||
// To avoid overlap with the close button:
|
// To avoid overlap with the close button:
|
||||||
hasRightPadding={isPartOfThread}
|
hasRightPadding={isPartOfThread}
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ export function TextInput({
|
|||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
placeholderTextColor={t.atoms.text_contrast_medium.color}
|
placeholderTextColor={t.atoms.text_contrast_medium.color}
|
||||||
keyboardAppearance={theme.colorScheme}
|
keyboardAppearance={theme.colorScheme}
|
||||||
autoFocus={true}
|
autoFocus={props.autoFocus !== undefined ? props.autoFocus : true}
|
||||||
allowFontScaling
|
allowFontScaling
|
||||||
multiline
|
multiline
|
||||||
scrollEnabled={false}
|
scrollEnabled={false}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export function TextInput({
|
|||||||
onPressPublish,
|
onPressPublish,
|
||||||
onNewLink,
|
onNewLink,
|
||||||
onFocus,
|
onFocus,
|
||||||
|
autoFocus,
|
||||||
}: TextInputProps) {
|
}: TextInputProps) {
|
||||||
const {theme: t, fonts} = useAlf()
|
const {theme: t, fonts} = useAlf()
|
||||||
const autocomplete = useActorAutocompleteFn()
|
const autocomplete = useActorAutocompleteFn()
|
||||||
@@ -244,20 +245,10 @@ export function TextInput({
|
|||||||
content: generateJSON(richTextToHTML(richtext), extensions, {
|
content: generateJSON(richTextToHTML(richtext), extensions, {
|
||||||
preserveWhitespace: 'full',
|
preserveWhitespace: 'full',
|
||||||
}),
|
}),
|
||||||
autofocus: 'end',
|
autofocus: autoFocus ? 'end' : null,
|
||||||
editable: true,
|
editable: true,
|
||||||
injectCSS: true,
|
injectCSS: true,
|
||||||
shouldRerenderOnTransaction: false,
|
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}) {
|
onUpdate({editor: editorProp}) {
|
||||||
const json = editorProp.getJSON()
|
const json = editorProp.getJSON()
|
||||||
const newText = editorJsonToText(json)
|
const newText = editorJsonToText(json)
|
||||||
|
|||||||
Reference in New Issue
Block a user