uncontrolled search input
This commit is contained in:
@@ -631,6 +631,7 @@ export function SearchScreen(
|
|||||||
useNonReactiveCallback(() => {
|
useNonReactiveCallback(() => {
|
||||||
if (isWeb) {
|
if (isWeb) {
|
||||||
setSearchText(queryParam)
|
setSearchText(queryParam)
|
||||||
|
textInput.current?.setNativeProps({text: queryParam})
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@@ -662,6 +663,7 @@ export function SearchScreen(
|
|||||||
const onPressClearQuery = React.useCallback(() => {
|
const onPressClearQuery = React.useCallback(() => {
|
||||||
scrollToTopWeb()
|
scrollToTopWeb()
|
||||||
setSearchText('')
|
setSearchText('')
|
||||||
|
textInput.current?.clear()
|
||||||
textInput.current?.focus()
|
textInput.current?.focus()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
@@ -741,6 +743,7 @@ export function SearchScreen(
|
|||||||
scrollToTopWeb()
|
scrollToTopWeb()
|
||||||
textInput.current?.blur()
|
textInput.current?.blur()
|
||||||
setShowAutocomplete(false)
|
setShowAutocomplete(false)
|
||||||
|
textInput.current?.setNativeProps({text: queryParam})
|
||||||
setSearchText(queryParam)
|
setSearchText(queryParam)
|
||||||
}, [setShowAutocomplete, setSearchText, queryParam])
|
}, [setShowAutocomplete, setSearchText, queryParam])
|
||||||
|
|
||||||
@@ -758,6 +761,7 @@ export function SearchScreen(
|
|||||||
|
|
||||||
const handleHistoryItemClick = React.useCallback(
|
const handleHistoryItemClick = React.useCallback(
|
||||||
(item: string) => {
|
(item: string) => {
|
||||||
|
textInput.current?.setNativeProps({text: item})
|
||||||
setSearchText(item)
|
setSearchText(item)
|
||||||
navigateToItem(item)
|
navigateToItem(item)
|
||||||
},
|
},
|
||||||
@@ -781,6 +785,7 @@ export function SearchScreen(
|
|||||||
} else {
|
} else {
|
||||||
setSearchText('')
|
setSearchText('')
|
||||||
navigation.setParams({q: ''})
|
navigation.setParams({q: ''})
|
||||||
|
textInput.current?.clear()
|
||||||
textInput.current?.focus()
|
textInput.current?.focus()
|
||||||
}
|
}
|
||||||
}, [navigation])
|
}, [navigation])
|
||||||
@@ -867,7 +872,7 @@ export function SearchScreen(
|
|||||||
<View style={[a.flex_1]}>
|
<View style={[a.flex_1]}>
|
||||||
<SearchInput
|
<SearchInput
|
||||||
ref={textInput}
|
ref={textInput}
|
||||||
value={searchText}
|
defaultValue={searchText}
|
||||||
onFocus={onSearchInputFocus}
|
onFocus={onSearchInputFocus}
|
||||||
onChangeText={onChangeText}
|
onChangeText={onChangeText}
|
||||||
onClearText={onPressClearQuery}
|
onClearText={onPressClearQuery}
|
||||||
|
|||||||
Reference in New Issue
Block a user