Skip to content

Commit 43491bb

Browse files
committed
Enhance AddScreen functionality to improve user experience during card entry. Added a reference for the source input field and modified the keyboard behavior to keep it open for rapid input of multiple cards.
1 parent 37b8aad commit 43491bb

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

app/(tabs)/add.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default function AddScreen() {
3030
const [saving, setSaving] = useState(false);
3131
const [toast, setToast] = useState<string | null>(null);
3232
const [keyboardOpen, setKeyboardOpen] = useState(false);
33+
const sourceRef = useRef<TextInputType>(null);
3334
const destinationRef = useRef<TextInputType>(null);
3435
const scrollRef = useRef<ScrollView>(null);
3536

@@ -66,7 +67,10 @@ export default function AddScreen() {
6667
setSourceText('');
6768
setDestinationText('');
6869
setToast(`Added “${word}”`);
69-
Keyboard.dismiss();
70+
// Keep the keyboard up for rapid entry of the next card.
71+
requestAnimationFrame(() => {
72+
sourceRef.current?.focus();
73+
});
7074
} finally {
7175
setSaving(false);
7276
}
@@ -116,6 +120,7 @@ export default function AddScreen() {
116120
) : null}
117121
<Text style={styles.label}>{activeDeck.sourceLanguage}</Text>
118122
<TextInput
123+
ref={sourceRef}
119124
value={sourceText}
120125
onChangeText={setSourceText}
121126
placeholder={`Word in ${activeDeck.sourceLanguage}`}
@@ -137,6 +142,7 @@ export default function AddScreen() {
137142
style={styles.input}
138143
autoCapitalize="none"
139144
returnKeyType="done"
145+
blurOnSubmit={false}
140146
onFocus={() => {
141147
requestAnimationFrame(() => {
142148
scrollRef.current?.scrollToEnd({ animated: true });

0 commit comments

Comments
 (0)