-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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: update bottom height when frame height is changed #36970
Conversation
Hi @lyqandy! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Base commit: 54f7b8b |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Reading around this I saw that the same function is called in the event of edit: Oh the frame here is that of the view, and not of the keyboard. |
This change seems good to me, but for someone not very familiar with this logic, could you explain the sequence of events/the math here a bit? |
Hi @NickGerleman , I have updated the Summary, you can take a look :). |
@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@NickGerleman merged this pull request in 5059ddc. |
…ed (facebook#36970) Summary: Fix this issue: facebook#29499 - We should change the bottom height if the frame height of KeyboardAvoidingView is changed In some scenarios, the height of `KeyboardAvoidingView` would be changed because its container is re-layouted. So `onLayout` of `KeyboardAvoidingView` may be triggered more than once. https://github.com/facebook/react-native/blob/bbc3657ff4efd0218e02ad9a3c73725a7f8a366c/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js#L114-L125 But at line 122 above, `_updateBottomIfNecessary ` would be called only for the first trigger of `onLayout`. That means, if the height of `KeyboardAvoidingView` is changed, the bottom height can't be updated. #### See the videos below: ##### before In this video, `KeyboardAvoidingView ` is rendered twice, and the height is changed from 844 to 753, `bottomHeight ` is not updated when the height changed, so there is a white gap below the `continue` button. Once I re-open the keyboard, `_updateBottomIfNecessary` is called again, then the white gap disappeared. https://user-images.githubusercontent.com/25719782/232962924-c69adc11-deb9-4426-9b5c-4e990a0470db.mp4 ##### after https://user-images.githubusercontent.com/25719782/232962956-a163020f-5f40-4d82-9f6c-5ee67416c489.mp4 ## Changelog: [GENERAL] [CHANGED] - change `_onLayout` to update bottom height when frame height is changed Pull Request resolved: facebook#36970 Reviewed By: rshest Differential Revision: D45138176 Pulled By: NickGerleman fbshipit-source-id: b7ce6d75622ed6e8f104ae0d8441e1cb97cfa15b
…ed (facebook#36970) Summary: Fix this issue: facebook#29499 - We should change the bottom height if the frame height of KeyboardAvoidingView is changed In some scenarios, the height of `KeyboardAvoidingView` would be changed because its container is re-layouted. So `onLayout` of `KeyboardAvoidingView` may be triggered more than once. https://github.com/facebook/react-native/blob/bbc3657ff4efd0218e02ad9a3c73725a7f8a366c/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js#L114-L125 But at line 122 above, `_updateBottomIfNecessary ` would be called only for the first trigger of `onLayout`. That means, if the height of `KeyboardAvoidingView` is changed, the bottom height can't be updated. #### See the videos below: ##### before In this video, `KeyboardAvoidingView ` is rendered twice, and the height is changed from 844 to 753, `bottomHeight ` is not updated when the height changed, so there is a white gap below the `continue` button. Once I re-open the keyboard, `_updateBottomIfNecessary` is called again, then the white gap disappeared. https://user-images.githubusercontent.com/25719782/232962924-c69adc11-deb9-4426-9b5c-4e990a0470db.mp4 ##### after https://user-images.githubusercontent.com/25719782/232962956-a163020f-5f40-4d82-9f6c-5ee67416c489.mp4 ## Changelog: [GENERAL] [CHANGED] - change `_onLayout` to update bottom height when frame height is changed Pull Request resolved: facebook#36970 Reviewed By: rshest Differential Revision: D45138176 Pulled By: NickGerleman fbshipit-source-id: b7ce6d75622ed6e8f104ae0d8441e1cb97cfa15b
Summary:
Fix this issue: #29499
In some scenarios, the height of
KeyboardAvoidingView
would be changed because its container is re-layouted. SoonLayout
ofKeyboardAvoidingView
may be triggered more than once.react-native/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
Lines 114 to 125 in bbc3657
But at line 122 above,
_updateBottomIfNecessary
would be called only for the first trigger ofonLayout
. That means, if the height ofKeyboardAvoidingView
is changed, the bottom height can't be updated.See the videos below:
before
In this video,
KeyboardAvoidingView
is rendered twice, and the height is changed from 844 to 753,bottomHeight
is not updated when the height changed, so there is a white gap below thecontinue
button. Once I re-open the keyboard,_updateBottomIfNecessary
is called again, then the white gap disappeared.before-fix.mp4
after
after-fix.mp4
Changelog:
[GENERAL] [CHANGED] - change
_onLayout
to update bottom height when frame height is changedTest Plan: