Extra space in KeyboardAccessoryView when using TabNavigation
mssod-alfa opened this issue · 3 comments
Hello,
I have created a demo app using the ViewExample Code as component (including a view with a TextInput) inside a TabNavigator. Running the app with IOS Simulator iPhone12 (or iPhone7) there is an extra space below the KeyboardAccessoryView.
If I use the StackNavigation the app runs correctly. It seems to be, that the height of the extra space below the KeyboardAccessoryView corresponds to the height of the tabbar, which is hidden by the keyboard.
Another observation: In android simulator you can see the tabbar below the KeyboardAccessoryView.
Has anyone suggestions who to get rid of the extra space under IOS or another solution to create a toolbar which is only visible if the keyboard is open due a text edit?
Many thanks in advance and best regards
`app.js
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import ViewExample from "./screens/ViewExample";
import { NavigationContainer, useLinking } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
export default function App() {
return (
<Tab.Navigator initialRouteName="ViewExample">
<Tab.Screen options={{title: "TAB1"}} name="TAB1" component={TabScreen1} />
<Tab.Screen options={{title: "ViewExample"}} name="ViewExample" component={ViewExample} />
<Tab.Screen options={{title: "TAB2"}} name="TAB2" component={TabScreen2} />
<Tab.Screen options={{title: "TAB3"}} name="TAB3" component={TabScreen3} />
</Tab.Navigator>
);
}
const TabScreen1 = () => {
return (
TAB SCREEN 1
)
}
const TabScreen2 = () => {
return (
TAB SCREEN 1
)
}
const TabScreen3 = () => {
return (
TAB SCREEN 1
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});`
`ViewExample.js
import React, { Component } from "react";
import { StyleSheet, View, Text, TextInput, Button, ScrollView } from "react-native";
import { KeyboardAccessoryView } from "react-native-keyboard-accessory";
class ViewExample extends Component {
render() {
return (
<Text style={{ padding: 12 }}>Text 1
<Text style={{ padding: 12 }}>Text 2
<TextInput style={{ padding: 12 }} placeholder="Eingabe 5" />
{({ isKeyboardVisible }) => (
{isKeyboardVisible && (
<Button
style={styles.textInputButton}
title="Send"
onPress={() => {}}
/>
)}
)}
);
}
}
ViewExample.navigationOptions = {
title: "View Example",
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
textInputView: {
padding: 8,
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
},
textInput: {
flexGrow: 1,
borderWidth: 1,
borderRadius: 10,
borderColor: "#CCC",
padding: 10,
fontSize: 16,
marginRight: 10,
textAlignVertical: "top",
},
textInputButton: {
flexShrink: 1,
},
});
export default ViewExample;`
@mssod-alfa did you find any solution?
No, the problem still exists.
@mssod-alfa , @Brma1048
Solution for this issue is addressed here. Please check it.