mirror of
https://github.com/Termix-SSH/Mobile.git
synced 2026-07-28 05:51:43 +02:00
fix: Keyboard disapears
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
Pressable,
|
||||
Dimensions,
|
||||
BackHandler,
|
||||
AppState,
|
||||
} from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useFocusEffect } from "@react-navigation/native";
|
||||
@@ -52,6 +53,7 @@ export default function Sessions() {
|
||||
const [screenDimensions, setScreenDimensions] = useState(
|
||||
Dimensions.get("window"),
|
||||
);
|
||||
const [keyboardType, setKeyboardType] = useState<any>('default');
|
||||
|
||||
useEffect(() => {
|
||||
const map: Record<string, React.RefObject<TerminalHandle>> = {
|
||||
@@ -91,6 +93,30 @@ export default function Sessions() {
|
||||
]),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = AppState.addEventListener("change", (nextAppState) => {
|
||||
if (nextAppState === "active") {
|
||||
if (
|
||||
sessions.length > 0 &&
|
||||
!isCustomKeyboardVisible &&
|
||||
!keyboardIntentionallyHiddenRef.current
|
||||
) {
|
||||
setTimeout(() => {
|
||||
setKeyboardType('email-address');
|
||||
setTimeout(() => {
|
||||
setKeyboardType('default');
|
||||
hiddenInputRef.current?.focus();
|
||||
}, 100);
|
||||
}, 250);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
subscription.remove();
|
||||
};
|
||||
}, [sessions.length, isCustomKeyboardVisible, activeSessionId]);
|
||||
|
||||
useEffect(() => {
|
||||
const keyboardDidHideListener = Keyboard.addListener(
|
||||
"keyboardDidHide",
|
||||
@@ -562,7 +588,7 @@ export default function Sessions() {
|
||||
pointerEvents="none"
|
||||
autoFocus={false}
|
||||
showSoftInputOnFocus={true}
|
||||
keyboardType="default"
|
||||
keyboardType={keyboardType}
|
||||
returnKeyType="default"
|
||||
blurOnSubmit={false}
|
||||
editable={true}
|
||||
|
||||
Reference in New Issue
Block a user