Android: Top inset is changed on keyboard dismissal when windowSoftInputMode = adjustPan
Not sure if this is the expected behavior, but when windowSoftInputMode is set to adjustPan, the top inset changes significantly after opening and dismissing the keyboard, i.e. the top inset can increase from 0 to over 100 after the keyboard is dismissed.
On Android, the adjustPan input mode automatically shifts the screen upward so that focused text inputs are moved above the software keyboard. This input mode is often recommended for handling input/keyboard avoidance on Android due to inconsistent behavior with KeyboardAvoidingView. I assume that when the app screen is shifted back downwards, the top inset value is set to the Y offset value used to pan the view back into its original position.
If this is expected behavior, it seems inconsistent in that the bottom inset doesn't change when the pan-upwards effect is performed upon opening the keyboard.
In my particular use case, the fact that the adjustPan mode affects insets makes it difficult to rely on the safe area context insets in places that are intended to account only for the presence of notches: I'm using the top inset to add top padding to a navigation bar but the padding value jumps in size after dismissing the keyboard.
Have same issue for Android 9.
- focus input field.
- hide keyboard with this button

- Got large top padding

as investigation for https://github.com/react-navigation/stack/issues/326 looks like if you have windowSoftInputMode is set to adjustPan code here: https://github.com/th3rdwave/react-native-safe-area-context/blob/master/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.java#L69 is executed when view is moved and keyboard is still visible, so its generating wrong number which is breaking calculation in next lines.
I am not Android dev and I am not sure if i can help fixing this in code 😭 hope my investigation is helping, at least something 👍
I decided to use react-native-status-bar-height in my project
Same issue here.
For now using react-native-status-bar-height as @ninjacoder95 suggested.
@ninjacoder95 @papigers I'm unsure how knowing the status bar height would get around this particular issue. The problem I ran into was the top inset increasing drastically after dismissing the keyboard, often to an arbitrary size not apparently based on the dimensions of other elements (status bar, keyboard height, notch sizes, etc).
Update: I saw the related react-navigation issue (https://github.com/react-navigation/stack/issues/326#issuecomment-570355089) — I'm not using this library but looks like the temporary fix is fixing your top inset to the status bar's height?
Thanks for the detailed repro, looking at this issue today.
Fixed in 0.7.0