react-native-community/hooks

useKeyboard does not respect iPad floating keyboard

jforaker opened this issue · 0 comments

Firstly thank you for the fine work!

TIL there is a thing called "floating keyboard" for iPad. You can enable it by pinching on the keyboard on iPad and disable it by un-pinching(?).

image

keyboardShown and keyboardHeight seem to misbehave when this is active and when you dismiss it.

Using the following code for the scenarios below:

  const { keyboardShown, keyboardHeight } = useKeyboard();
  console.log('keyboardHeight: ', keyboardHeight);
  console.log('keyboardShown: ', keyboardShown);

When Floating Keyboard is open from the start (maybe you already set this in another app), it logs:

 LOG  keyboardHeight:  0
 LOG  keyboardShown:  false

And then when you swipe to remove the floating keyboard and replace it with the regular keyboard, it logs (this is good):

 LOG  keyboardHeight:  337
 LOG  keyboardShown:  true

And then, pinch to enable the floating keyboard again, and it logs (this is bad):

 LOG  keyboardHeight:  337
 LOG  keyboardShown:  false

It seems like at the very least, keyboardHeight should be set to 0 on the last scenario. That way you can inform the your KeyboardAvoidingView to be enabled={false}. That is how I discovered the issue.

There is a decent answer here about detecting the floating keyboard. Perhaps some additional fields could be added to the hook to make it more useful.