We're running into a specific bug on iOS/iPadOS
which seems to be triggered when the iPad is showing the floating (iphone-like) keyboard on screen (instead of the anchored one)
Our issue is specific to React Native and the KeyboardAvoidingView
component. When the component renders and the keyboard is floating, the KeyboardAvoidingView
completely mis-calculated the height required for the keyboard and hides about 95% of the screen height instead.
The KeyboardAvoidingView
itself doesn't seem to have a way to detect whether or not the floating keyboard is on.
Is there a particular API that can be tapped into to detect this keyboard mode so we can turn off the KeyboardAvoidingView
for it?
The Keyboard events (keyboardWillShow
, keyboardDidShow
, etc) don't seem to return any specific clues.
There is no such mode enum/indicator (at least for now), but having keyboard frame information
public class let keyboardFrameBeginUserInfoKey: String // NSValue of CGRect public class let keyboardFrameEndUserInfoKey: String // NSValue of CGRect
in corresponding keyboard notifications
public class let keyboardWillShowNotification: NSNotification.Name public class let keyboardDidShowNotification: NSNotification.Name public class let keyboardWillHideNotification: NSNotification.Name public class let keyboardDidHideNotification: NSNotification.Name public class let keyboardWillChangeFrameNotification: NSNotification.Name public class let keyboardDidChangeFrameNotification: NSNotification.Name
relative to screen bounds
UIScreen.main.bounds
it is possible to detect if the frame of keyboard is at the edge of screen bottom or floating.
Schematically it would be like
keyboardAttached = NSMaxX(screenBounds) == NSMaxX(keyboardFrame) &&
NSMaxY(screenBounds) == NSMaxY(keyboardFrame) &&
NSWidth(screenBounds) == NSWidth(keyboardFrame)