mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-04 16:06:41 +00:00
fix: move from recipients to subject to body with the return key
This commit is contained in:
@@ -662,6 +662,9 @@ export default function ComposeScreen({ route, navigation }: Props) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const editorRef = React.useRef<RichTextEditorHandle>(null);
|
const editorRef = React.useRef<RichTextEditorHandle>(null);
|
||||||
|
const subjectRef = React.useRef<TextInput>(null);
|
||||||
|
const plainBodyRef = React.useRef<TextInput>(null);
|
||||||
|
const [subjectFocused, setSubjectFocused] = React.useState(false);
|
||||||
const isPickingSuggestion = React.useRef(false);
|
const isPickingSuggestion = React.useRef(false);
|
||||||
// Track inline-image placeholders that haven't yet been rewritten to cid:
|
// Track inline-image placeholders that haven't yet been rewritten to cid:
|
||||||
// until send time. Maps cid → blobId/type/name/size.
|
// until send time. Maps cid → blobId/type/name/size.
|
||||||
@@ -2249,7 +2252,13 @@ export default function ComposeScreen({ route, navigation }: Props) {
|
|||||||
isPickingSuggestion.current = false;
|
isPickingSuggestion.current = false;
|
||||||
}, 200);
|
}, 200);
|
||||||
}}
|
}}
|
||||||
onSubmitEditing={() => addTyped(field)}
|
// Return turns typed text into a chip; on an empty field it
|
||||||
|
// moves on to the subject.
|
||||||
|
returnKeyType="next"
|
||||||
|
onSubmitEditing={() => {
|
||||||
|
if (inputFor(field).trim()) addTyped(field);
|
||||||
|
else subjectRef.current?.focus();
|
||||||
|
}}
|
||||||
blurOnSubmit={false}
|
blurOnSubmit={false}
|
||||||
keyboardType="email-address"
|
keyboardType="email-address"
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
@@ -2383,12 +2392,24 @@ export default function ComposeScreen({ route, navigation }: Props) {
|
|||||||
<View style={styles.fieldRow}>
|
<View style={styles.fieldRow}>
|
||||||
<Text style={styles.fieldLabel}>{t('email_composer.subject', 'Subject')}</Text>
|
<Text style={styles.fieldLabel}>{t('email_composer.subject', 'Subject')}</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
ref={subjectRef}
|
||||||
disableFullscreenUI
|
disableFullscreenUI
|
||||||
style={styles.subjectInput}
|
style={styles.subjectInput}
|
||||||
placeholder={t('email_composer.subject_placeholder', 'Subject')}
|
placeholder={t('email_composer.subject_placeholder', 'Subject')}
|
||||||
placeholderTextColor={c.textMuted}
|
placeholderTextColor={c.textMuted}
|
||||||
value={subject}
|
value={subject}
|
||||||
onChangeText={setSubject}
|
onChangeText={setSubject}
|
||||||
|
// Unfocused, a long subject shows from its start ("Re: …"), not
|
||||||
|
// scrolled to its end.
|
||||||
|
selection={subjectFocused ? undefined : SELECTION_START}
|
||||||
|
onFocus={() => setSubjectFocused(true)}
|
||||||
|
onBlur={() => setSubjectFocused(false)}
|
||||||
|
returnKeyType="next"
|
||||||
|
blurOnSubmit={false}
|
||||||
|
onSubmitEditing={() => {
|
||||||
|
if (plainTextMode) plainBodyRef.current?.focus();
|
||||||
|
else editorRef.current?.focus();
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
@@ -2407,6 +2428,7 @@ export default function ComposeScreen({ route, navigation }: Props) {
|
|||||||
|
|
||||||
{plainTextMode ? (
|
{plainTextMode ? (
|
||||||
<TextInput
|
<TextInput
|
||||||
|
ref={plainBodyRef}
|
||||||
disableFullscreenUI
|
disableFullscreenUI
|
||||||
style={styles.plainEditor}
|
style={styles.plainEditor}
|
||||||
multiline
|
multiline
|
||||||
@@ -2876,6 +2898,8 @@ export default function ComposeScreen({ route, navigation }: Props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SELECTION_START = { start: 0, end: 0 };
|
||||||
|
|
||||||
/** Gap between the tablet composer panel and the screen edges. */
|
/** Gap between the tablet composer panel and the screen edges. */
|
||||||
const PANEL_MARGIN = 24;
|
const PANEL_MARGIN = 24;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user