Skip to content

Commit abad892

Browse files
committed
tweak android keyboard fix
1 parent 3d4a18f commit abad892

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/components/KeyboardCompatibleView/KeyboardCompatibleView.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import {
33
AppState,
44
AppStateStatus,
5+
Dimensions,
56
EmitterSubscription,
67
Keyboard,
78
KeyboardAvoidingViewProps,
@@ -65,14 +66,17 @@ export class KeyboardCompatibleView extends React.Component<
6566

6667
/**
6768
* When the StatusBar is translucent there is an issue
68-
* where the relative keyboard height is returned as the StatusBar
69-
* height instead of 0 when closed.
69+
* where the relative keyboard height is returned incorrectly
70+
* instead of 0 when closed.
7071
*/
71-
if (
72-
Platform.OS === 'android' &&
73-
relativeHeight === StatusBar.currentHeight
74-
) {
75-
return 0;
72+
if (Platform.OS === 'android') {
73+
const barHeights =
74+
Dimensions.get('screen').height - Dimensions.get('window').height;
75+
if (
76+
relativeHeight <= Math.max(barHeights, StatusBar.currentHeight ?? 0)
77+
) {
78+
return 0;
79+
}
7680
}
7781

7882
// Calculate the displacement needed for the view such that it

0 commit comments

Comments
 (0)