-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Android side-effect issue with KeyboardProvider #584
Comments
Hello @hyochan When you wrap the app in So in your case:
The ways how you can solve your problem:
Let me know if you want me to explain any aspect in more details 🙏
Unfortunately it's not achievable in a current reality. The best thing that you can do is to use |
Remove platform specific code as suggested in https://github.com/kirillzyusko/react-native-keyboard-controller/issues/584\#issuecomment-2348514591
@kirillzyusko Thank you so much for the detailed and excellent response. Thanks to your explanation, I have gained a better understanding of your library. As per your suggestion, I removed the platform-specific code and used the keyboard.mp4Additionally, if you have more references regarding the statement "the Thank you. |
You can read about that for example here - facebook/react-native#41918
I'll check why it happens in nearest time! |
Okay @hyochan Sorry for initial misleading - in your case you should have
So as you can see you had a difference which is equal to And this space is roughly equal to the size of your text input - that's why it gets hidden behind the keyboard. In your case you should artificially increase the area of a blue rectangle and you can do that by adding I hope I explained why it doesn't work as you expect 😅 Thank you for providing such a detailed and good quality reproduction example ❤️ Let me know if you have any additional questions - I'll be happy to answer on all of them 😊 |
Thank you for your efforts. Unfortunately, we are still encountering the same issue on Android. The field animates to the top of the upper side of the keyboard, meaning it remains covered. We have tested all your solutions, but none of them have worked. I am quite surprised that this bug exists in React Native. I am considering migrating to Flutter, although it is not an easy decision. Some bugs force you to consider alternatives. If you have any solution that can be applied with clear steps, we would be very grateful. Eg demo which we can understand your sulution since your last reply is very complicated. Demo code is appreciate. All our app forms are covered by this bug, and the React Native team remains silent. |
@kirillzyusko Thanks for the great explanation 👍👍
However, I am still curious why This issue needs to be clearly understood to prevent side effects in other views that use @beshoo I am not getting your statement.
I think this should be explained in more details. Providing some code examples and recordings would be very helpful. |
@beshoo you can clone the example app https://github.com/kirillzyusko/react-native-keyboard-controller/tree/main/example and see how everything is handled there. This app has a plenty of use cases and covers almost all basic interactions with the keyboard. If you run the code in example app and it works there, but the same code produces different output in your app - it means that something is misconfigured, and it's easier to fix a misconfiguration rather than switching to a new framework/technology 🤷♂️ If you can replace the code in example app with your own code and the bug persist in example application, then feel to free to open a new issue and I'll be glad to help to resolve the problem.
It's very hard to say what exactly causes the problem, because I don't see the code, don't see the output (including view hierarchy) and can not test/interact with this code. If you think it's a problem in this library - feel free to open a new issue with reproduction example and I'll try to do all my best to help you. |
It's all handled in react-native-keyboard-controller/src/components/KeyboardAvoidingView/index.tsx Lines 78 to 79 in e2198af
Well, feel free to correct me here, but I think that But if some elements are placed above the In the end I implemented test example and covered it by e2e tests to assure that
On iOS if you don't specify
So I think that a component from I didn't find time to run your project on iOS - but if you run it with If you want to fully match default keyboard handling from Android, then you can wrap your entire app in <GestureHandlerRootView
style={css`
flex: 1;
`}
>
<RootProvider initialThemeType={localThemeType as ColorSchemeName}>
<KeyboardAvoidingView
behavior="padding"
style={{flex: 1, width: '100%'}}
>
<StatusBarBrightness />
<Layout />
</KeyboardAvoidingView>
</RootProvider>
</GestureHandlerRootView> Then layout will be measured correctly and you don't need to think about headers and other elements (because all of them will be rendered inside But sometimes having just Let me know if you have any other questions - will be happy to answer on them as well! 😊 🙌 |
@kirillzyusko, I feel that wrapping the entire view with Your detailed explanation has made things much clearer, but I wanted to highlight a few concerns I encountered during implementation:
|
@hyochan if re-render doesn't cause a layout re-calculation then
Interesting. It should just call
This is a very good question and honestly I don't know the answer. This component heavily relies on But it's actually very strange - if it works with one mode (i. e. I honestly don't know why |
Below is keyboard.with.height.mp4Below is keyboard.with.padding.mp4Would this information be more helpful in identifying the cause of the issue? |
@hyochan well, that's what I thought. In case of Later on it resizes back to proper size, but the key thing is that at some point of time it applies double space (i. e. In case of So it makes me thinking that |
@kirillzyusko If it's alright with you, I’d like to write and upload a document about this issue. Would that be okay? |
Yes, sure! I think I attempted to clarify it in https://github.com/kirillzyusko/react-native-keyboard-controller/pull/381but if you can write a better documentation that will explain everything in more details then I'm happy to merge it in docs 😊 |
I'm going to close that issue since I believe I gave an answer on the question. If you want to make adjustments to the documentation - feel free to do that (it's highly appreciated)! |
Describe the bug
Hello, thank you for creating such a great library. I've been using
KeyboardAvoidingView
in React Native for a while, but recently needed the keyboard functionality fromreact-native-keyboard-controller
, which allowed me to implement the keyboard behavior I wanted. I really appreciate your work.However, I encountered an issue where
KeyboardAvoidingView
from the corereact-native
package only causes a side-effect on Android. Specifically, when I wrap my app layout withKeyboardProvider
, theKeyboardAvoidingView
inreact-native
package stops working, but this issue is only happening on Android.It seems like the issue was resolved by setting
padding
instead of leaving thebehavior
asundefined
, and also by providing akeyboardVerticalOffset
, but the exact cause and behavior remain unclear, which leaves me feeling a bit uncertain. I would like to better understand how this change impacts screens whereKeyboardAvoidingView
is already being used. Specifically, I’d like to know what effects this adjustment may have on the existing views, especially in terms of layout shifts or keyboard interaction, and whether this might introduce any potential side effects. Could you explain how this configuration influences the layout and behavior in detail?Code snippet
RootProvider.tsx
_layout.tsx
index.tsx
Repo for reproducing
I would be highly appreciate if you can provide repository for reproducing your issue. It can significantly reduce the time for discovering and fixing the problem.
To Reproduce
Steps to reproduce the behavior:
bun install
or use your package manager.git checkout 16a313a4d8ae1d4a5fb1cdd07529f440527c3dcb
.react-native-keyboard-controller
and wrapped withKeyboardProvider
and test that keyboard is not showing this time.Expected behavior
Even when using
react-native-keyboard-controller
and wrapping the app withKeyboardProvider
, the existingKeyboardAvoidingView
fromreact-native
should continue to function without issues on Android.Screenshots
Video Previews
1. Initial Commit
16a313a.mp4
2. Install and wrap with KeyboardProvider
41f812e.mp4
3. Naive workaround
61bc6f3.mp4
4. Test other options with useKeyboardAnimation
dd8d452.mp4
Smartphone (please complete the following information):
Additional context
N/A
The text was updated successfully, but these errors were encountered: