From b841d0018d7364ef82dde1a89ec6a79efe4e74e2 Mon Sep 17 00:00:00 2001 From: Amanda Bullington <35536439+albullington@users.noreply.github.com> Date: Wed, 15 May 2024 15:35:29 -0700 Subject: [PATCH] Autofocus search bar by default; closes #1532 (#1559) --- .../Explore/SearchScreens/ExploreTaxonSearch.js | 9 +-------- src/components/SharedComponents/SearchBar.js | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/components/Explore/SearchScreens/ExploreTaxonSearch.js b/src/components/Explore/SearchScreens/ExploreTaxonSearch.js index 6fdb8f430..dae2a3291 100644 --- a/src/components/Explore/SearchScreens/ExploreTaxonSearch.js +++ b/src/components/Explore/SearchScreens/ExploreTaxonSearch.js @@ -9,7 +9,7 @@ import { import { View } from "components/styledComponents"; import type { Node } from "react"; import React, { - useCallback, useLayoutEffect, useRef, useState + useCallback, useState } from "react"; import { FlatList } from "react-native"; import { useIconicTaxa } from "sharedHooks"; @@ -24,12 +24,6 @@ const DROP_SHADOW = getShadowForColor( colors.darkGray, { const ExploreTaxonSearch = ( ): Node => { const [taxonQuery, setTaxonQuery] = useState( "" ); const navigation = useNavigation( ); - // Ref for the input field - const inputRef = useRef( null ); - // Focus input field on mount - useLayoutEffect( ( ) => { - inputRef.current?.focus(); - }, [] ); const iconicTaxa = useIconicTaxa( { reload: false } ); const taxonList = useTaxonSearch( taxonQuery ); @@ -63,7 +57,6 @@ const ExploreTaxonSearch = ( ): Node => { handleTextChange={setTaxonQuery} value={taxonQuery} testID="SearchTaxon" - input={inputRef} /> diff --git a/src/components/SharedComponents/SearchBar.js b/src/components/SharedComponents/SearchBar.js index 5c5a6024b..d753538a3 100644 --- a/src/components/SharedComponents/SearchBar.js +++ b/src/components/SharedComponents/SearchBar.js @@ -27,7 +27,7 @@ type Props = { // Ensure this component is placed outside of scroll views const SearchBar = ( { - autoFocus = false, + autoFocus = true, clearSearch, containerClass, handleTextChange,