mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: **Convert keyboard position to window coordinate space on iOS** The keyboard frame passed to keyboardWillChangeFrame is in the screen's coordinate space [1]. It needs to be converted to the window's coordinate space to support Slide Over and Stage Manager. [1] https://developer.apple.com/documentation/uikit/uikeyboardframeenduserinfokey?language=objc |Before|After| |---|---| ||| **Improve detached keyboard detection on iOS** The iOS keyboard may be in one of three states: 1) floating (previously supported with a width check) 2) split 3) or undocked. In addition, when using Stage Manager, the keyboard may be wider than the window itself. This would cause the floating keyboard check to incorrectly set the bottom position to zero. Instead, rely on the fact that the UIKeyboardWillHideNotification notification is sent when the keyboard is in any detached state. This requires listening for UIKeyboardWillShowNotification instead of UIKeyboardWillChangeFrameNotification. This is fine, since the show notification is also sent when the keyboard resizes while open. Combined with the coordinate system adjustments in the previous commit, this also fixes an issue with Stage Manager, since the keyboard may be attached yet wider than the application window. |Before|After| |---|---| ||| ||| ||| ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [iOS] [FIXED] - Keyboard events are converted to window coordinate space [iOS] [FIXED] - Improve detached keyboard detection, support Stage Manager on iOS Pull Request resolved: https://github.com/facebook/react-native/pull/48131 Test Plan: See screenshots above. Reviewed By: yungsters Differential Revision: D67337314 Pulled By: cipolleschi fbshipit-source-id: abe872ac8c83336f316917074f72cdb23a39caab