1- import { FC , useEffect , useState , useRef } from "react"
1+ import { useEffect , useState , useRef } from "react"
22import {
33 TextInput ,
4+ TextInputProps ,
45 Animated ,
56 Pressable ,
67 StyleProp ,
@@ -12,17 +13,23 @@ import searchDark from "assets/menu/searchDark.svg"
1213import { Icon } from "components/Icon"
1314import { useTranslation } from "react-i18next"
1415
16+ interface PoliSearchBarProps extends Pick < TextInputProps , "autoFocus" > {
17+ onChange : ( searchKey : string ) => void
18+ style ?: StyleProp < ViewStyle >
19+ }
20+
1521/**
1622 * the search bar, which requests a search everytime the input text changes
1723 */
18- export const PoliSearchBar : FC < {
19- onChange : ( searchKey : string ) => void
20- style ?: StyleProp < ViewStyle >
21- } > = ( { onChange, style } ) => {
24+ export const PoliSearchBar = ( {
25+ autoFocus = false ,
26+ onChange,
27+ style,
28+ } : PoliSearchBarProps ) => {
2229 const { fieldBackground, fieldText, bodyText, isLight, palette } =
2330 usePalette ( )
2431
25- const [ isFocused , setIsFocused ] = useState ( false )
32+ const [ isFocused , setIsFocused ] = useState ( autoFocus )
2633 const shadowAnim = useRef ( new Animated . Value ( 0 ) ) . current
2734 const inputText = useRef < TextInput > ( null )
2835
@@ -98,6 +105,7 @@ export const PoliSearchBar: FC<{
98105 onChangeText = { onChange }
99106 onFocus = { ( ) => setIsFocused ( true ) }
100107 onBlur = { ( ) => setIsFocused ( false ) }
108+ autoFocus = { autoFocus }
101109 />
102110 < Pressable
103111 style = { {
0 commit comments