freshyo/docs/address-form-keyboard-fix.md
2026-10-13 13:51:16 +05:30

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

  • ScrollView pattern.

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 (undefined on Android, where softwareKeyboardLayoutMode: "resize" is set in app.json).
  • The scroll container now fills its parent (flex-1); padding moved to contentContainerStyle. This also fixed a pre-existing layout bug where pb-32 (viewport padding) plus a hardcoded maxHeight: 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 (SystemInputAssistantView top 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 --noEmit clean 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.