Skip to content

Commit c088bc2

Browse files
Banyel3claude
andcommitted
fix(ui): dismiss keyboard on tap-outside / scroll in Screen
Non-scroll screens (login) were a plain View with no keyboard dismissal — tapping outside an input left the keyboard stuck. Wrap non-scroll bodies in TouchableWithoutFeedback(Keyboard.dismiss) (buttons still handle their own touch), and add keyboardDismissMode=on-drag to scroll screens. Fixes it everywhere the shared Screen is used. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e605a19 commit c088bc2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

packages/ui/src/components.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import React, { useRef } from 'react';
22
import {
33
ActivityIndicator,
44
Animated,
5+
Keyboard,
56
PanResponder,
67
Pressable,
78
ScrollView,
89
StyleSheet,
910
Text,
11+
TouchableWithoutFeedback,
1012
View,
1113
ViewStyle,
1214
} from 'react-native';
@@ -37,13 +39,21 @@ export function Screen({
3739
{scroll ? (
3840
<ScrollView
3941
contentContainerStyle={styles.scrollBody}
42+
// persistTaps keeps buttons tappable while the keyboard is up;
43+
// on-drag dismisses the keyboard when you start scrolling.
4044
keyboardShouldPersistTaps="handled"
45+
keyboardDismissMode="on-drag"
4146
showsVerticalScrollIndicator={false}
4247
>
4348
{children}
4449
</ScrollView>
4550
) : (
46-
<View style={styles.body}>{children}</View>
51+
// Non-scroll screens (e.g. login): tap any empty area to dismiss the
52+
// keyboard. Buttons/inputs handle their own touch, so only background
53+
// taps reach this handler.
54+
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
55+
<View style={styles.body}>{children}</View>
56+
</TouchableWithoutFeedback>
4757
)}
4858
</SafeAreaView>
4959
);

0 commit comments

Comments
 (0)