Please sign in to comment.
BREAKING: Fix modal resizing on keyboard show
Summary: This changes modal behavior to resize when the keyboard appears/disappears. Previously, the modal would not react in any way, or it would pan above to bring the TextInput into view. Resizing is the correct behavior for android. This is not trivial, as in, setting the flag, because of the combination of react native laying out all views and the system reacting to the keyboard appearance in a weird way. Namely: - if `windowTranslucentStatus` is not set, the system will just call `onSizeChanged` on the dialog's content view, and everything works nicely - with `windowTranslucentStatus` set, the system will consider the dialog as a full screen view that doesn't resize. In order for it to resize, the base view of the layout needs to have `setFitsSystemWindows(true)` called on it. This is needed, so that the system can call layout on that base view with the new value of `paddingBottom` that coincides with the height of the keyboard. Neat. We fix this by wrapping our existing content view (mHostView) in a simple FrameLayout that has `setFitsSystemWindows` set. That way, `mHostView` will have `onSizeChanged` called on itself with the correct new size of the dialog. This has the fortunate consequence of our layout now also getting `paddingTop` as the size of the status bar, which means that we can remove the JS `top` hack in Modal, which was necessary for no view getting drawn under the status bar. This behavior is set as default, since that is the default correct Android behavior. Reviewed By: astreet Differential Revision: D3913784 fbshipit-source-id: 4378ada21f466dc7ac6e357abeca10b88009ca3f
- Loading branch information...
Showing with 18 additions and 7 deletions.