Skip to content

KeyboardAvoidingView with behavior="height" produces incorrect layout when navigating through a stack of screens with auto-focused inputs. #949

@KirillRodichevUtorg

Description

@KirillRodichevUtorg

Describe the bug
KeyboardAvoidingView with behavior="height" produces incorrect layout when navigating through a stack of screens with auto-focused inputs.

Code snippet

<KeyboardAvoidingView
  behavior="height" // important
  keyboardVerticalOffset={100}
  style={styles.content}
>
<TextInput
  autoFocus // important
  placeholder="Username"
  placeholderTextColor="#7C7C7C"
  style={styles.textInput}
/>
<TouchableOpacity onPress={() => {
  navigation.navigate(ScreenNames.KEYBOARD_AVOIDING_VIEW_COPY)
}}>
  <Text>Submit</Text>
</TouchableOpacity>

To Reproduce

  1. Duplicate the example KeyboardAvoidingViewExample screen (e.g. KeyboardAvoidingViewExampleCopy) and place it in the same stack.
  2. Add autoFocus to the top <TextInput /> on both screens.
  3. Hardcode behavior="height" for <KeyboardAvoidingView /> on both screens.
  4. Add stack navigation: navigate from KeyboardAvoidingViewExample screen to KeyboardAvoidingViewExampleCopy.
  5. Navigate to KeyboardAvoidingViewExample, and while having focused TextInput, navigate to KeyboardAvoidingViewExampleCopy

Note, that when I navigate to KeyboardAvoidingViewExampleCopy with blurred <TextInput /> on KeyboardAvoidingViewExample, it works fine

Expected behavior
Layout of KeyboardAvoidingViewExampleCopy is the same as for KeyboardAvoidingViewExample

Screenshots

Smartphone (please complete the following information):

  • Device: Galaxy A13
  • OS: Android 14
  • RN version: 0.77.1
  • RN architecture: old
  • JS engine: Hermes
  • Library version: 1.17.1

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions