question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keyboard disappears in searchbar component

See original GitHub issue

Hi, I’m using version 1.2.4 SearchBar component but when i use it in android device the keyboard disappears after every key input! here is my code: const [searchBrand, setSearchBrand] = useState(''); const searchFilterFunction = text => { setSearchBrand(text); }; const renderHeader = () => { return ( <SearchBar placeholder="Type Here..." onChangeText={searchFilterFunction} value={searchBrand} /> ); };

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

6reactions
codermugcommented, Oct 3, 2019

Thank you, the issue caused because i used <SearchBar> inside Flatlist headercomponent prop

  <FlatList ListHeaderComponent={renderHeader}..... 

but when i used it outside the component it works properly.

<View style={styles.container}> <SearchBar placeholder="Type Here..." onChangeText={searchFilterFunction} value={searchBrand} clearIcon={null} /> <FlatList data={brandsData} renderItem={({item}) => <RenderSingleItem item={item} />} /> </View>

0reactions
Foxxiblakcommented, Jan 20, 2022

It still doesn’t work if SearchBar is added to the Header of the FlatList example:

` const [search, setSearch] = useState(“”);

function updateSearch(value = ""):void {
    setSearch(value)
}

const onClearSearch = () => {
    setSearch('');
}

const renderHeader = () => {
    return (
        <SearchBar
            placeholder={"Text ..."}
            placeholderTextColor={"#808080"}
            onChangeText={updateSearch}
            onClear={() => onClearSearch()}
            value={search}
            containerStyle={styles.searchContainer}
            inputContainerStyle={ styles.inputContainer }
            inputStyle={styles.searchInput}
        />
    )
}

return (
    <View style={styles.container}>
        <FlatList
            data={[]}
            renderItem={({item}) => renderItem(item)}
            ListHeaderComponent={renderHeader}
            showsVerticalScrollIndicator={false}
            keyExtractor={(item, index) => (item + index).toString()}
        />
    </View>
);`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Keyboard disappearing after each key press in a SearchBar?
Just some general direction. You need some form of debouncing. Either find a search component that has that or implemented your own.
Read more >
React Native: Searchbar disappears after typing one single letter
The SearchBar now lets only type one single letter, then the keyboard disappears and you have to click the input field again to...
Read more >
Keyboard missing in App Libray search bar…
Tap once in the search bar, you will see the keyboard. When you scroll, the keyboard disappears. Then tap on an app you...
Read more >
Google search bar widget closes keyboard after typing one letter
Tap on the Google Search widget, the widget opens the search screen, keyboard automatically appears allowing me to type. However, immediately ...
Read more >
React Native — SearchBar in FlatList loses focus after typing
The problem I encountered is that after typing one character the search bar loses focus and the keyboard disappears — it's almost like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found