How to Handle Soft Keyboard Overlap and Input Focus Issues in React Native Forms

How to Handle Soft Keyboard Overlap and Input Focus Issues in React Native Forms

by | Nov 20, 2026 | Uncategorized | 0 comments

You build a login or signup screen, you wrap everything in KeyboardAvoidingView, and the soft keyboard still covers the last two inputs. On iOS it half works. On Android it does nothing, or it jumps, or the screen shrinks in a weird way. If you searched for react native keyboard avoiding view not working, you already know this is one of the most frustrating layout bugs in the framework.

This guide is a practical troubleshooting playbook: how to diagnose the real cause, platform specific behavior differences, the exact ScrollView configuration that works, Android edge to edge issues introduced with recent SDK targets, and how to move focus between multiple text inputs without the keyboard closing between each field.

Quick diagnosis: match your symptom to the cause

Before changing code randomly, identify which bug you actually have. Most reports fall into one of these buckets.

Symptom Most likely cause Where to look
Nothing moves at all, on both platforms KeyboardAvoidingView has no height (missing flex: 1) or is not an ancestor of the inputs Component tree and styles
Works on iOS, does nothing on Android Wrong behavior value, or windowSoftInputMode is adjustPan AndroidManifest.xml / app.json
Content moves but too much or too little Missing or wrong keyboardVerticalOffset with a navigation header Header height calculation
Keyboard overlaps content after upgrading Android target SDK 35/36 Edge to edge is enforced, the app now receives IME insets instead of being resized Edge to edge config and safe area insets
Tapping a button while keyboard is open needs two taps Missing keyboardShouldPersistTaps ScrollView props
Keyboard closes and reopens between fields Default submit behavior blurs the input before focusing the next one TextInput submitBehavior / refs
Fails only inside a Modal or bottom sheet Android modals do not resize the window the same way Modal container
mobile phone keyboard app

Why KeyboardAvoidingView behaves differently on iOS and Android

The core misunderstanding is this: iOS and Android solve the keyboard problem at two completely different levels.

  • iOS does nothing automatically. The OS never resizes your app window, so React Native has to listen to keyboard events and manually add padding, change height, or shift position. That is exactly what KeyboardAvoidingView does.
  • Android historically handled it at the window level through android:windowSoftInputMode. With adjustResize, the Android window shrinks and your flex layout reflows by itself. KeyboardAvoidingView then risks doing the adjustment a second time, which produces the famous double offset.

This is why copy pasting a snippet from a blog post written for one platform usually breaks the other.

The behavior prop, explained properly

behavior What it does Recommended for
padding Adds bottom padding equal to keyboard height. Children must be able to shrink. iOS, screens with a ScrollView or a flexible container
height Reduces the container height. Can cause visible jumps and clipped content. Android with adjustPan, simple fixed layouts
position Translates the whole container upward. Breaks absolute positioned footers. Rare, single input centered screens
undefined No JS side adjustment at all, relies on the Android window resize. Android with adjustResize and no edge to edge

Rule of thumb: padding on iOS, and on Android either undefined (if adjustResize works) or height (if you are stuck with adjustPan).

Fix 1: the baseline that actually works on both platforms

Start from this structure. KeyboardAvoidingView must be the screen level container, must have flex: 1, and must not be wrapped in a View that clips it.

import { useHeaderHeight } from '@react-navigation/elements';
import { KeyboardAvoidingView, Platform, ScrollView, StyleSheet, TextInput } from 'react-native';

export default function SignupScreen() {
  const headerHeight = useHeaderHeight();

  return (
    <KeyboardAvoidingView
      style={styles.flex}
      behavior={Platform.OS === 'ios' ? 'padding' : undefined}
      keyboardVerticalOffset={Platform.OS === 'ios' ? headerHeight : 0}
    >
      <ScrollView
        style={styles.flex}
        contentContainerStyle={styles.content}
        keyboardShouldPersistTaps="handled"
        keyboardDismissMode={Platform.OS === 'ios' ? 'interactive' : 'on-drag'}
        automaticallyAdjustKeyboardInsets={Platform.OS === 'ios'}
      >
        <TextInput style={styles.input} placeholder="Email" />
        <TextInput style={styles.input} placeholder="Password" secureTextEntry />
      </ScrollView>
    </KeyboardAvoidingView>
  );
}

const styles = StyleSheet.create({
  flex: { flex: 1 },
  content: { flexGrow: 1, padding: 16, gap: 12, justifyContent: 'center' },
  input: { borderWidth: 1, borderColor: '#ccc', borderRadius: 8, padding: 12 },
});

Three details that people miss in this snippet:

  1. contentContainerStyle={{ flexGrow: 1 }} and not flex: 1. With flex: 1 the content can never grow taller than the viewport, so it can never scroll out of the keyboard.
  2. keyboardShouldPersistTaps="handled" so the first tap on a button registers instead of only dismissing the keyboard.
  3. automaticallyAdjustKeyboardInsets is an iOS only ScrollView prop that handles the inset natively. On many simple forms it alone removes the need for KeyboardAvoidingView on iOS.

Do not nest KeyboardAvoidingView inside a ScrollView

The order matters. KeyboardAvoidingView goes outside, ScrollView goes inside. The reverse produces a container that cannot resize and the keyboard simply covers the content.

mobile phone keyboard app

Fix 2: the Android configuration checklist

Most Android only failures are configuration, not code.

Bare React Native

In android/app/src/main/AndroidManifest.xml, check the activity:

<activity
  android:name=".MainActivity"
  android:windowSoftInputMode="adjustResize"
  ... />

Expo managed projects

In app.json or app.config.js:

{
  "expo": {
    "android": {
      "softwareKeyboardLayoutMode": "resize"
    }
  }
}

Then rebuild the native project. A config change like this never applies through a JS reload, and that alone explains a large share of “I changed it and nothing happened” reports.

Important pairing: if you set resize, use behavior={undefined} on Android. If you set pan, use behavior="height". Mixing resize with behavior="padding" is the classic double offset bug where the form jumps far above the keyboard.

Fix 3: Android 15/16, edge to edge and target SDK 35+

This is the newest and least documented cause, and it is behind many recent GitHub issues where “KeyboardAvoidingView stopped working after an upgrade”.

Since Android 15, apps targeting SDK 35 and above are drawn edge to edge by default. The window no longer resizes itself when the IME appears. Instead the system reports the keyboard as an inset, and your layout must consume it. If your app relied on adjustResize shrinking the window, that mechanism silently stops being enough.

What to do:

  • Make sure you are on a recent React Native version where edge to edge keyboard insets are handled, and that react-native-safe-area-context and react-native-screens are updated at the same time. Mismatched versions are a frequent cause.
  • Do not hardcode a bottom padding. Read the bottom inset from useSafeAreaInsets() and apply it to the content container, not to the KeyboardAvoidingView itself.
  • If you are still fighting it after a day, switch the screen to react-native-keyboard-controller, which reads the IME inset directly and works consistently in edge to edge mode.
import { useSafeAreaInsets } from 'react-native-safe-area-context';

const insets = useSafeAreaInsets();

<ScrollView
  contentContainerStyle={{ paddingBottom: insets.bottom + 24, flexGrow: 1 }}
  keyboardShouldPersistTaps="handled"
/>

Fix 4: keyboardVerticalOffset and navigation headers

KeyboardAvoidingView measures its own frame relative to the window. If a native header, a tab bar or a status bar sits above it, the computed offset is wrong by exactly that height. The symptom is a form that moves, but stops a few dozen pixels short or overshoots.

import { useHeaderHeight } from '@react-navigation/elements';
import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs';

const headerHeight = useHeaderHeight();
const tabBarHeight = useBottomTabBarHeight();

<KeyboardAvoidingView
  style={{ flex: 1 }}
  behavior={Platform.OS === 'ios' ? 'padding' : undefined}
  keyboardVerticalOffset={Platform.OS === 'ios' ? headerHeight : tabBarHeight}
/>

Never hardcode values like 64 or 88. They break on notched devices, on Dynamic Island devices and on Android devices with a translucent status bar.

mobile phone keyboard app

Fix 5: ScrollView configuration for long forms

For a form with more than four or five inputs, moving the container is not enough. You also need the focused field to scroll into view.

<ScrollView
  ref={scrollRef}
  contentContainerStyle={{ flexGrow: 1, paddingBottom: 120 }}
  keyboardShouldPersistTaps="handled"
  keyboardDismissMode="on-drag"
  showsVerticalScrollIndicator={false}
  automaticallyAdjustKeyboardInsets={Platform.OS === 'ios'}
/>

Key points:

  • A generous paddingBottom on the content container gives the last input room to scroll above the keyboard.
  • Use a ScrollView for forms, not a FlatList, unless the list is genuinely long. Virtualized lists unmount off screen inputs and lose their state.
  • If you must use a FlatList, set keyboardShouldPersistTaps="handled" on the list itself, not on a wrapper.

Scrolling a specific input into view manually

import { useRef } from 'react';

const scrollRef = useRef(null);

const scrollToInput = (node) => {
  node?.measureLayout(
    scrollRef.current.getInnerViewNode?.() ?? scrollRef.current,
    (x, y) => scrollRef.current.scrollTo({ y: Math.max(y - 80, 0), animated: true }),
    () => {}
  );
};

<TextInput onFocus={(e) => scrollToInput(e.target)} />

Fix 6: moving focus between multiple text inputs

A second very common complaint: tapping “Next” on the keyboard closes it, then it reopens for the following field, and the layout flickers each time.

The cause is the default submit behavior, which blurs the input on submit. On modern React Native versions, use submitBehavior="submit" (the replacement for the deprecated blurOnSubmit) so the keyboard never dismisses between fields.

import { useRef } from 'react';
import { TextInput } from 'react-native';

export function LoginForm() {
  const passwordRef = useRef(null);

  return (
    <>
      <TextInput
        placeholder="Email"
        keyboardType="email-address"
        autoCapitalize="none"
        autoComplete="email"
        textContentType="emailAddress"
        returnKeyType="next"
        submitBehavior="submit"
        onSubmitEditing={() => passwordRef.current?.focus()}
      />

      <TextInput
        ref={passwordRef}
        placeholder="Password"
        secureTextEntry
        autoComplete="current-password"
        textContentType="password"
        returnKeyType="done"
        onSubmitEditing={handleSubmit}
      />
    </>
  );
}

Checklist for clean focus handling:

  1. One useRef per input, or an array of refs for dynamic forms.
  2. returnKeyType="next" on every field except the last one, which gets "done" or "go".
  3. submitBehavior="submit" on every field that forwards focus (use blurOnSubmit={false} on older React Native versions).
  4. Set autoComplete and textContentType so autofill does not fight your focus logic.
  5. Avoid calling focus() inside a setTimeout. If you need it, the problem is usually elsewhere in the layout.

Fix 7: keyboard issues inside a Modal

On Android, a React Native Modal creates its own window, and the activity level adjustResize does not always apply to it. Two practical workarounds:

  • Put a KeyboardAvoidingView inside the Modal as the direct child, with behavior="height" on Android.
  • Better: avoid Modal for forms. Use an absolutely positioned overlay inside the screen, or a bottom sheet library that exposes keyboard aware props.
mobile phone keyboard app

When to stop fighting and replace KeyboardAvoidingView

The official documentation itself describes KeyboardAvoidingView as good for prototyping but requiring platform specific configuration and offering little customization. If your form is non trivial, a dedicated library will save you days.

Solution Strengths Trade offs
Built in KeyboardAvoidingView Zero dependency, fine for one or two inputs Platform branching, no interactive tracking, fragile with edge to edge
react-native-keyboard-controller Frame by frame keyboard animation, KeyboardAwareScrollView, drop in KeyboardAvoidingView replacement, works with edge to edge and the new architecture Native dependency, needs a dev build (not Expo Go)
react-native-avoid-softinput Native side adjustment, very little JS work Less control over the animation, smaller ecosystem
react-native-keyboard-aware-scroll-view Familiar API, lots of old tutorials Largely unmaintained, poor fit with recent React Native versions

The recommended modern setup

// App.tsx
import { KeyboardProvider } from 'react-native-keyboard-controller';

export default function App() {
  return (
    <KeyboardProvider>
      <Navigation />
    </KeyboardProvider>
  );
}

// FormScreen.tsx
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';

export function FormScreen() {
  return (
    <KeyboardAwareScrollView
      bottomOffset={24}
      contentContainerStyle={{ padding: 16, gap: 12 }}
      keyboardShouldPersistTaps="handled"
    >
      {/* your inputs */}
    </KeyboardAwareScrollView>
  );
}

No Platform.OS branching, no keyboardVerticalOffset maths, and the focused field is scrolled into view automatically with the keyboard animation curve.

Final debugging checklist

  1. Does the KeyboardAvoidingView have flex: 1 and is it the outermost screen container?
  2. Is the ScrollView inside it, with contentContainerStyle={{ flexGrow: 1 }}?
  3. Is behavior correct per platform, and does it match your Android soft input mode?
  4. Did you rebuild natively after changing the manifest or app.json?
  5. Is keyboardVerticalOffset derived from the real header or tab bar height?
  6. Are react-native-safe-area-context and react-native-screens on versions compatible with your React Native version?
  7. Is edge to edge enabled on Android and are you consuming the bottom inset?
  8. Is keyboardShouldPersistTaps="handled" set on the scrollable component itself?
  9. Are you testing on a real device? Simulators with a hardware keyboard attached hide the soft keyboard entirely and give false results.
  10. Still broken after all of the above? Move the screen to react-native-keyboard-controller instead of adding more patches.

FAQ

Why does KeyboardAvoidingView work on iOS but not on Android?

Because Android resizes the app window at the OS level while iOS does not. If your Android activity uses adjustResize, the layout already reflows and a JS behavior of padding either does nothing useful or doubles the offset. Use behavior={undefined} on Android with adjustResize, or behavior="height" with adjustPan.

What is the correct behavior value to use?

padding on iOS, and undefined or height on Android depending on your soft input mode. The commonly copied line behavior={Platform.OS === 'ios' ? 'padding' : 'height'} works for simple screens but causes jumps on Android layouts that already resize.

My form stopped working after upgrading React Native or Expo. What changed?

The most frequent culprit is the Android target SDK moving to 35 or above, which enforces edge to edge drawing. The window no longer shrinks when the keyboard appears, so layouts that depended on adjustResize break. Consume the IME and safe area insets, or move to a keyboard inset aware library.

How do I keep the keyboard open when moving to the next input?

Give each input a ref, set returnKeyType="next" and submitBehavior="submit", then call nextRef.current?.focus() inside onSubmitEditing. On older React Native versions, use blurOnSubmit={false} instead of submitBehavior.

Why does my button need two taps while the keyboard is open?

The first tap is consumed to dismiss the keyboard. Add keyboardShouldPersistTaps="handled" to the ScrollView or FlatList wrapping your form.

Should I use flex: 1 or flexGrow: 1 on contentContainerStyle?

Use flexGrow: 1. With flex: 1 the content is locked to the viewport height and can never scroll, which is why the last field stays hidden behind the keyboard.

Is react-native-keyboard-controller worth the native dependency?

For any production form with several inputs, yes. It removes platform branching, animates in sync with the keyboard, and behaves correctly under edge to edge on Android. The only requirement is a custom dev build rather than Expo Go.

Need help shipping a reliable React Native form?

Keyboard handling is one of those problems that looks like a five minute fix and turns into a two day refactor across every screen. If your team is dealing with layout regressions after an Android target SDK bump, or wants a keyboard strategy applied consistently across an entire app, our mobile engineers at Box Software can audit your codebase and implement a single, maintainable pattern.