Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyboardAvoidingView does not handle the onLayout prop correctly #32608

Closed
JeffreyHyer opened this issue Nov 16, 2021 · 0 comments
Closed

KeyboardAvoidingView does not handle the onLayout prop correctly #32608

JeffreyHyer opened this issue Nov 16, 2021 · 0 comments

Comments

@JeffreyHyer
Copy link

Description

import { KeyboardAvoidingView } from 'react-native'

const doOnLayout = ({ nativeEvent: { layout } }) => {
  console.log(layout)
}

<KeyboardAvoidingView onLayout={doOnLayout}>
  {/* ... */}
</KeyboardAvoidingView>

When the onLayout prop is provided the KeyboardAvoidingView doesn't adjust the view to avoid overlap with the keyboard. If you remove the onLayout prop everything works as expected.

This happens because the KeyboardAvoidingView component relies on the onLayout prop internally, so when we supply the prop ourselves it overrides the internal implementation.

This behavior is seen regardless of the value supplied to the behavior prop.

Version

0.66.0

Output of react-native info

N/A

Steps to reproduce

Use the KeyboardAvoidingView and pass in the onLayout prop.

Snack, code example, screenshot, or link to a repository

No response

nawbc pushed a commit to NawbExplorer/react-native that referenced this issue Dec 7, 2021
Summary:
Resolves facebook#32608

This PR updates the `KeyboardAvoidingView` to correctly handle the `onLayout` prop.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - `onLayout` prop is handled correctly in `<KeyboardAvoidingView>`

Pull Request resolved: facebook#32609

Test Plan:
| Current Behavior with the `onLayout` prop specified | After applying fix |
|---|---|
| ![Simulator Screen Recording - iPhone 11 - 2021-11-17 at 14 44 09](https://user-images.githubusercontent.com/1406082/142287541-0dbcf137-4d72-4ab6-9367-ac42bdf5aed9.gif) | ![Simulator Screen Recording - iPhone 11 - 2021-11-17 at 14 44 28](https://user-images.githubusercontent.com/1406082/142287611-c7424a6c-b590-48f7-8d74-e96543eab41c.gif) |

Reviewed By: kacieb

Differential Revision: D32481315

Pulled By: philIip

fbshipit-source-id: 2f65440f4996152e4133211136f2920026149ee9
@facebook facebook locked as resolved and limited conversation to collaborators Nov 24, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants