fix cancel button on search posts screen (#7912)

This commit is contained in:
Samuel Newman
2025-03-06 18:06:13 +00:00
committed by GitHub
parent a7db0bac6f
commit 1c16c6ef0a
+7 -2
View File
@@ -735,12 +735,17 @@ export function SearchScreenShell({
setShowAutocomplete(false)
if (isWeb) {
// Empty params resets the URL to be /search rather than /search?q=
navigation.replace('Search', {})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {q: _q, ...parameters} = (route.params ?? {}) as {
[key: string]: string
}
// @ts-expect-error route is not typesafe
navigation.replace(route.name, parameters)
} else {
setSearchText('')
navigation.setParams({q: ''})
}
}, [setShowAutocomplete, setSearchText, navigation])
}, [setShowAutocomplete, setSearchText, navigation, route.params, route.name])
const onSubmit = React.useCallback(() => {
navigateToItem(searchText)