Skip to content

Sometimes KeyboardAvoidingView does not animate keyboard entering on iOS #1086

@itsramiel

Description

@itsramiel

Describe the bug
I have a case where the KeyboardAvoidingView is no longer animating the entering of the Keyboard on iOS. The setup I had looked like this:

import { useState } from 'react';
import { TextInput, View } from 'react-native';
import {
  KeyboardAvoidingView,
  KeyboardProvider,
} from 'react-native-keyboard-controller';
import Animated, { FadeInRight, FadeOutRight } from 'react-native-reanimated';

function App() {
  const [isFocused, setIsFocused] = useState(false);

  const onFocus = () => {
    setIsFocused(true);
  };

  const onBlur = () => {
    setIsFocused(false);
  };

  return (
    <KeyboardProvider>
      <KeyboardAvoidingView
        behavior="translate-with-padding"
        style={{ flex: 1 }}
      >
        <View style={{ flex: 1, backgroundColor: 'red' }} />
        <View style={{ flexDirection: 'row' }}>
          <TextInput
            style={{
              padding: 12,
              borderWidth: 1,
              borderColor: 'black',
              flex: 1,
            }}
            onFocus={onFocus}
            onBlur={onBlur}
          />
          {isFocused ? (
            <Animated.View
              entering={FadeInRight}
              exiting={FadeOutRight}
              style={{ width: 50, height: 50, backgroundColor: 'green' }}
            />
          ) : null}
        </View>
      </KeyboardAvoidingView>
    </KeyboardProvider>
  );
}

export default App;

Screen Recordings

iOS Android
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-08-14.at.06.23.05.mp4
Screen.Recording.2025-08-14.at.6.28.36.AM.mov

The previous example includes animated views with layout animations. I was hoping to reproduce it with simpler config and I was able to do that by using a regular view but setFocus after a timeout:

diff --git a/App.tsx b/App.tsx
index 8e0c6e6..8f0cba2 100644
--- a/App.tsx
+++ b/App.tsx
@@ -4,17 +4,20 @@ import {
   KeyboardAvoidingView,
   KeyboardProvider,
 } from 'react-native-keyboard-controller';
-import Animated, { FadeInRight, FadeOutRight } from 'react-native-reanimated';
 
 function App() {
   const [isFocused, setIsFocused] = useState(false);
 
   const onFocus = () => {
-    setIsFocused(true);
+    setTimeout(() => {
+      setIsFocused(true);
+    }, 0);
   };
 
   const onBlur = () => {
-    setIsFocused(false);
+    setTimeout(() => {
+      setIsFocused(false);
+    }, 0);
   };
 
   return (
@@ -36,11 +39,7 @@ function App() {
             onBlur={onBlur}
           />
           {isFocused ? (
-            <Animated.View
-              entering={FadeInRight}
-              exiting={FadeOutRight}
-              style={{ width: 50, height: 50, backgroundColor: 'green' }}
-            />
+            <View style={{ width: 50, height: 50, backgroundColor: 'green' }} />
           ) : null}
         </View>
       </KeyboardAvoidingView>
Full Example
import { useState } from 'react';
import { TextInput, View } from 'react-native';
import {
  KeyboardAvoidingView,
  KeyboardProvider,
} from 'react-native-keyboard-controller';

function App() {
  const [isFocused, setIsFocused] = useState(false);

  const onFocus = () => {
    setTimeout(() => {
      setIsFocused(true);
    }, 0);
  };

  const onBlur = () => {
    setTimeout(() => {
      setIsFocused(false);
    }, 0);
  };

  return (
    <KeyboardProvider>
      <KeyboardAvoidingView
        behavior="translate-with-padding"
        style={{ flex: 1 }}
      >
        <View style={{ flex: 1, backgroundColor: 'red' }} />
        <View style={{ flexDirection: 'row' }}>
          <TextInput
            style={{
              padding: 12,
              borderWidth: 1,
              borderColor: 'black',
              flex: 1,
            }}
            onFocus={onFocus}
            onBlur={onBlur}
          />
          {isFocused ? (
            <View style={{ width: 50, height: 50, backgroundColor: 'green' }} />
          ) : null}
        </View>
      </KeyboardAvoidingView>
    </KeyboardProvider>
  );
}

export default App;

Screen Recordings

iOS Android
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-08-14.at.06.34.30.mp4
Screen.Recording.2025-08-14.at.6.34.36.AM.mov

Repo for reproducing
https://github.com/itsramiel/KeyboardIos

To Reproduce

  1. Clone repo
  2. Run on iOS
  3. tap on input at the bottom
  4. Observe how the view is not animated

Expected behavior
I expect the view to animated

Smartphone (please complete the following information):

  • Desktop OS: [e.g. Windows 10, MacOS 10.15.5]
  • Device: iPhone 16 Pro
  • OS: 18.5
  • RN version: 0.81.0, 0.80.1(tested on both)
  • RN architecture: new
  • JS engine: Hermes
  • Library version: 1.18.4

Additional context

  • ⚠️⚠️ Sometimes the first time the keyboard opens it animates but susbsequent ones do not. please make sure to try focusing multiple times
  • The issue is with translate-wth-padding. padding seems to work fine

Metadata

Metadata

Assignees

Labels

KeyboardAvoidingView 🧪Anything related to KeyboardAvoidingView componentrepro providedIssue contains reproduction repository/code🐛 bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions