chore: only focus when search button is tapped

This commit is contained in:
Adrian Castro
2024-03-06 08:41:00 +01:00
parent fdfec592a9
commit 7dfd14842b

View File

@@ -1,6 +1,5 @@
import { useCallback, useContext, useEffect, useRef, useState } from "react"; import { useContext, useEffect, useRef, useState } from "react";
import { TextInput, View } from "react-native"; import { TextInput, View } from "react-native";
import { useFocusEffect } from "expo-router";
import { FontAwesome5 } from "@expo/vector-icons"; import { FontAwesome5 } from "@expo/vector-icons";
import Colors from "@movie-web/tailwind-config/colors"; import Colors from "@movie-web/tailwind-config/colors";
@@ -23,19 +22,6 @@ export function SearchBar({
}; };
}, [focusSearchInputRef]); }, [focusSearchInputRef]);
useFocusEffect(
useCallback(() => {
// When the screen is focused
const focus = () => {
setTimeout(() => {
inputRef?.current?.focus();
}, 20);
};
focus();
return focus; // cleanup
}, []),
);
const handleChange = (text: string) => { const handleChange = (text: string) => {
setKeyword(text); setKeyword(text);
onSearchChange(text); onSearchChange(text);