4.3 KiB
Address form: keyboard not appearing (iOS) — fix
Status: fixed (user-ui). Applies to iOS simulator and physical devices.
File changed: apps/user-ui/src/components/AddressForm.tsx
Symptom
On iOS, tapping an input in the address form sometimes focused the field (cursor + iOS edit menu visible) but the software keyboard did not appear on screen, or appeared off-screen. Other forms in the app (login, complaints, order notes) showed the keyboard normally.
Captured evidence on the iOS 18.6 simulator: the input was focused while the keyboard's
SystemInputAssistantView bounds were [0,896][414,1211] — i.e. starting at the bottom
edge of the 896pt screen and extending below it. A second tap brought the keyboard up.
Root cause
AddressForm was the only form still using react-native-keyboard-aware-scroll-view
(installed 0.9.5, last published ~2021) via KeyboardAwareScrollView.
That library measures the focused input with the legacy bridge APIs:
node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js
-> findNodeHandle / UIManager / measureInWindow / TextInputState
The app runs react-native@0.79.6 with newArchEnabled: true (Fabric/TurboModules).
Those legacy measurement APIs are unreliable under the New Architecture (stale/zero
measurements, bad ordering), so the library's scroll-into-view / keyboard handling can
leave the keyboard mis-positioned or suppressed.
Every other working form in the app uses React Native's built-in KeyboardAvoidingView
instead, which is why they were unaffected.
Is this simulator-only?
No. The affected code is the library's JS/native HOC, which ships and runs identically on physical iPhones. The simulator simply reproduced it. Whether you see it depends on geometry and timing (keyboard height, screen size, content height, safe area, animation timing), so on a device the visible symptom could be "keyboard shows but the field is scrolled wrong/hidden" rather than exactly "no keyboard".
The fix
Replace the legacy KeyboardAwareScrollView with the app's standard KeyboardAvoidingView
ScrollViewpattern.
Before:
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view';
<KeyboardAwareScrollView
style={[tw`px-4 pt-4 pb-32 bg-white`, { maxHeight: Dimensions.get('window').height * 0.7 }]}
keyboardShouldPersistTaps="always"
keyboardDismissMode="on-drag"
>
...
</KeyboardAwareScrollView>
After:
import { View, Modal, ScrollView, KeyboardAvoidingView, Platform } from 'react-native';
<KeyboardAvoidingView
style={tw`flex-1 bg-white`}
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
>
<ScrollView
style={tw`flex-1`}
contentContainerStyle={tw`px-4 pt-4 pb-10`}
keyboardShouldPersistTaps="handled"
showsVerticalScrollIndicator={false}
>
...
</ScrollView>
</KeyboardAvoidingView>
Notes:
behavior="padding"on iOS (undefinedon Android, wheresoftwareKeyboardLayoutMode: "resize"is set inapp.json).- The scroll container now fills its parent (
flex-1); padding moved tocontentContainerStyle. This also fixed a pre-existing layout bug wherepb-32(viewport padding) plus a hardcodedmaxHeight: 70%left a blank band at the bottom and clipped content on the full-screen add-address step.
Related wrapper fix (the sheet has no built-in height): apps/user-ui/app/(drawer)/(tabs)/me/addresses/index.tsx
wraps the form in a sized container because RawBottomDialog renders children bare:
<RawBottomDialog open={modalVisible} onClose={() => setModalVisible(false)}>
<View style={[tw`bg-white rounded-t-2xl`, { height: Dimensions.get('window').height * 0.85 }]}>
<AddressForm ... />
</View>
</RawBottomDialog>
Verification
- iOS simulator (iOS 18.6): tapping an input shows the keyboard on-screen
(
SystemInputAssistantViewtop at y≈550 instead of y=896); the focused field scrolls into view and the submit button remains reachable. - End-to-end: added an address via "Attach Current Location"; the region switched and Home loaded.
tsc --noEmitclean for user-ui.- No dependency changes; no migrations.
Remaining risk
apps/user-ui/app/(auth)/login.tsx still uses KeyboardAwareScrollView from the same
legacy library. It is the same latent risk on devices under the New Architecture; migrate
to KeyboardAvoidingView for consistency when convenient.