Fix keyboard issues in search
This commit is contained in:
parent
23d98b9557
commit
67906db720
1 changed files with 7 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React, {useEffect, useState, useMemo} from 'react'
|
import React, {useEffect, useState, useMemo, useRef} from 'react'
|
||||||
import {StyleSheet, Text, TextInput, TouchableOpacity, View} from 'react-native'
|
import {StyleSheet, Text, TextInput, TouchableOpacity, View} from 'react-native'
|
||||||
import {ViewHeader} from '../com/util/ViewHeader'
|
import {ViewHeader} from '../com/util/ViewHeader'
|
||||||
import {SuggestedFollows} from '../com/discover/SuggestedFollows'
|
import {SuggestedFollows} from '../com/discover/SuggestedFollows'
|
||||||
|
@ -11,6 +11,7 @@ import {MagnifyingGlassIcon} from '../lib/icons'
|
||||||
|
|
||||||
export const Search = ({navIdx, visible, params}: ScreenParams) => {
|
export const Search = ({navIdx, visible, params}: ScreenParams) => {
|
||||||
const store = useStores()
|
const store = useStores()
|
||||||
|
const textInput = useRef<TextInput>(null)
|
||||||
const [query, setQuery] = useState<string>('')
|
const [query, setQuery] = useState<string>('')
|
||||||
const autocompleteView = useMemo<UserAutocompleteViewModel>(
|
const autocompleteView = useMemo<UserAutocompleteViewModel>(
|
||||||
() => new UserAutocompleteViewModel(store),
|
() => new UserAutocompleteViewModel(store),
|
||||||
|
@ -21,6 +22,7 @@ export const Search = ({navIdx, visible, params}: ScreenParams) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
autocompleteView.setup()
|
autocompleteView.setup()
|
||||||
|
textInput.current?.focus()
|
||||||
store.nav.setTitle(navIdx, `Search`)
|
store.nav.setTitle(navIdx, `Search`)
|
||||||
}
|
}
|
||||||
}, [store, visible, name])
|
}, [store, visible, name])
|
||||||
|
@ -35,6 +37,7 @@ export const Search = ({navIdx, visible, params}: ScreenParams) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const onSelect = (handle: string) => {
|
const onSelect = (handle: string) => {
|
||||||
|
textInput.current?.blur()
|
||||||
store.nav.navigate(`/profile/${handle}`)
|
store.nav.navigate(`/profile/${handle}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +47,9 @@ export const Search = ({navIdx, visible, params}: ScreenParams) => {
|
||||||
<View style={styles.inputContainer}>
|
<View style={styles.inputContainer}>
|
||||||
<MagnifyingGlassIcon style={styles.inputIcon} />
|
<MagnifyingGlassIcon style={styles.inputIcon} />
|
||||||
<TextInput
|
<TextInput
|
||||||
|
ref={textInput}
|
||||||
placeholder="Type your query here..."
|
placeholder="Type your query here..."
|
||||||
|
selectTextOnFocus
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
onChangeText={onChangeQuery}
|
onChangeText={onChangeQuery}
|
||||||
/>
|
/>
|
||||||
|
@ -97,6 +102,7 @@ const styles = StyleSheet.create({
|
||||||
color: colors.gray3,
|
color: colors.gray3,
|
||||||
},
|
},
|
||||||
input: {
|
input: {
|
||||||
|
flex: 1,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue