-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
The keyboard in floating mode is having problem. #29473
Comments
|
Hi @000xuandu thanks for the issue. Since this affects iPad, could you provide a repo that demonstrates this issue? |
We experienced a similar problem, when a floating keyboard was dismissed the height calculation was off so we ended up with a blank screen (because everything was pushed off the screen). When the floating keyboard is dismissed we get the following when calculating the relativeKeyboardHeight
We did a workaround to just disable the KeyboardAvoidingView when the keyboard was floating by checking if the keyboard width is the same as the screen width
Then in your component
Don't know if the appropriate solution is to disable keyboard avoiding view when the keyboard is floating (as the user can move it wherever) or how to make the component avoid the keyboard when it's moving around. |
@Gyran thanks for your workaround! You probably wanted to removeListener in the return function of useEffect I refactored it a bit, and designed it as a HOC to replace the original KeyboardAvoidingView I gonna share the code
|
@torcoste of course, updated the example with |
Yes |
Created a minimal reproducible example here: https://github.com/Gyran/RNFloatingKeyboardIssue Would an acceptable solution be to just disable the keyboard avoiding view when a user has a floating keyboard? If so, I could try to implement that in the React Native repo. |
thanks a lot it works for me! |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Are there any plans to fix this in the built in |
Is this issue fixed? |
Summary: On iPadOS, users can change the kind of keyboard displayed onscreen, going from normal keyboard, to split keyboard (one half on the left of the screen, one half on the right), or a floating keyboard that you can move around the screen. When a non-normal kind of keyboard is used, `<KeyboardAvoidingView>` calculations are all wrong and, depending on the `behavior` prop, can make your screen completely hidden. This PR attempts to detect that the keyboard is not the "normal displayed-at-bottom-of-screen" keyboard, and forces `enable={false}` if this happens. The approach of comparing the keyboard width with the window width comes from this comment: #29473 (comment) A better fix might be to detect the kind of keyboard used, but this involves native code changes and I do not know iOS enough to do that. In addition, I have not found an easy way to do it using iOS APIs after a quick search. I also chose to cache the window width as a class attribute. Maybe this is not needed as `Dimensions.get('window').width` is very fast and can be called on every keyboard event? This fixes #44068 and #29473 ## Changelog: [IOS] [FIXED] - Fix `<KeyboardAvoidingView>` with floating keyboard on iPadOS Pull Request resolved: #44859 Test Plan: Tested using RNTester and the "Keyboard Avoiding View with different behaviors" example. Before: https://github.com/facebook/react-native/assets/42070/111598a3-286c-464d-8db8-73afb35cd7f9 After: https://github.com/facebook/react-native/assets/42070/0b3bc94f-8b67-4f42-8a83-e11555080268 Reviewed By: cortinico Differential Revision: D62844854 Pulled By: cipolleschi fbshipit-source-id: 577444be50019572955a013969d78178914b5b8d
Summary: On iPadOS, users can change the kind of keyboard displayed onscreen, going from normal keyboard, to split keyboard (one half on the left of the screen, one half on the right), or a floating keyboard that you can move around the screen. When a non-normal kind of keyboard is used, `<KeyboardAvoidingView>` calculations are all wrong and, depending on the `behavior` prop, can make your screen completely hidden. This PR attempts to detect that the keyboard is not the "normal displayed-at-bottom-of-screen" keyboard, and forces `enable={false}` if this happens. The approach of comparing the keyboard width with the window width comes from this comment: #29473 (comment) A better fix might be to detect the kind of keyboard used, but this involves native code changes and I do not know iOS enough to do that. In addition, I have not found an easy way to do it using iOS APIs after a quick search. I also chose to cache the window width as a class attribute. Maybe this is not needed as `Dimensions.get('window').width` is very fast and can be called on every keyboard event? This fixes #44068 and #29473 ## Changelog: [IOS] [FIXED] - Fix `<KeyboardAvoidingView>` with floating keyboard on iPadOS Pull Request resolved: #44859 Test Plan: Tested using RNTester and the "Keyboard Avoiding View with different behaviors" example. Before: https://github.com/facebook/react-native/assets/42070/111598a3-286c-464d-8db8-73afb35cd7f9 After: https://github.com/facebook/react-native/assets/42070/0b3bc94f-8b67-4f42-8a83-e11555080268 Reviewed By: cortinico Differential Revision: D62844854 Pulled By: cipolleschi fbshipit-source-id: 577444be50019572955a013969d78178914b5b8d
Summary: On iPadOS, users can change the kind of keyboard displayed onscreen, going from normal keyboard, to split keyboard (one half on the left of the screen, one half on the right), or a floating keyboard that you can move around the screen. When a non-normal kind of keyboard is used, `<KeyboardAvoidingView>` calculations are all wrong and, depending on the `behavior` prop, can make your screen completely hidden. This PR attempts to detect that the keyboard is not the "normal displayed-at-bottom-of-screen" keyboard, and forces `enable={false}` if this happens. The approach of comparing the keyboard width with the window width comes from this comment: #29473 (comment) A better fix might be to detect the kind of keyboard used, but this involves native code changes and I do not know iOS enough to do that. In addition, I have not found an easy way to do it using iOS APIs after a quick search. I also chose to cache the window width as a class attribute. Maybe this is not needed as `Dimensions.get('window').width` is very fast and can be called on every keyboard event? This fixes #44068 and #29473 [IOS] [FIXED] - Fix `<KeyboardAvoidingView>` with floating keyboard on iPadOS Pull Request resolved: #44859 Test Plan: Tested using RNTester and the "Keyboard Avoiding View with different behaviors" example. Before: https://github.com/facebook/react-native/assets/42070/111598a3-286c-464d-8db8-73afb35cd7f9 After: https://github.com/facebook/react-native/assets/42070/0b3bc94f-8b67-4f42-8a83-e11555080268 Reviewed By: cortinico Differential Revision: D62844854 Pulled By: cipolleschi fbshipit-source-id: 577444be50019572955a013969d78178914b5b8d
Description
My app has been rejected by apple due to interface issues.
After half a day I queried the problem, I finally realized the problem was at the
floating keyboard
of iPadOS 13.When the keyboard went into floating mode, KeyboardAvoidingView worked incorrectly and destroyed my interface structure.
React Native version:
Expected Results
What I want now to be able to recognize a certain event is to notify the keyboard to switch to floating mode, from which I will handle my UI.
Snack, code example, screenshot, or link to a repository:
Screen capture when keyboard is in anchor mode.
Screen capture when the keyboard is in floating mode.
Code:
The text was updated successfully, but these errors were encountered: