Skip to content

Commit c9e6387

Browse files
committed
navigate to GlobalSearch in writing mode
1 parent 25325f6 commit c9e6387

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/components/PoliSearchBar.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { FC, useEffect, useState, useRef } from "react"
1+
import { useEffect, useState, useRef } from "react"
22
import {
33
TextInput,
4+
TextInputProps,
45
Animated,
56
Pressable,
67
StyleProp,
@@ -12,17 +13,23 @@ import searchDark from "assets/menu/searchDark.svg"
1213
import { Icon } from "components/Icon"
1314
import { 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={{

src/pages/GlobalSearch.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const GlobalSearch: MainStackScreen<"GlobalSearch"> = () => {
9595
<PoliSearchBar
9696
style={styles.searchBar}
9797
onChange={input => setInput(input)}
98+
autoFocus
9899
/>
99100
<View style={styles.tagsContainer}>
100101
{SEARCH_TAGS.map(tag => (

0 commit comments

Comments
 (0)