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.

SearchBar's TextInput gets cleared with showLoadingIcon prop.

See original GitHub issue

Description

  1. Explain what you did Tried to use the SearchBar component with the showLoadingIcon prop.
  2. What you expected to happen ActivityIndicator should show and hide according to the value provided.
  3. What actually happens ActivityIndicator works as expected, but the TextInput gets cleared afterwards.

Also please include the version of react-native-elements that you are using. Version 0.18.4 with RN 0.50.1

Reproduction Steps and Sample Code

Just use a SearchBar component with showLoadingIcon prop. https://snack.expo.io/HyFj7bseG

Solution

Found out that commenting the following code in Search.js (lines 86-88) fixes the problem, but I’m not really sure what causes it.

clearIcon && showLoadingIcon && { paddingRight: 50 },
((clearIcon && !showLoadingIcon) ||
(!clearIcon && showLoadingIcon)) && { paddingRight: 30 },

Can you suggest a possible fix that would address this issue? Ideally, you should be able to submit a PR to fix it. See our contributing guide for more details.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

4reactions
xavier-villelegiercommented, Nov 29, 2017

@kmorales13 Ah on Android! I have this behavior too. I think that on Android you have to control the component, to avoid loosing the content of the TextInput at each render. Check this example ✌️

2reactions
laurence-myerscommented, Mar 16, 2018

I have also run into this issue.

If setting the “value” prop is the official solution, can the documentation be updated to say this is required for Android?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Having loading on Searchbar and TextInput Components #1705
I am just thinking, would it be nice to toggle the clear icon with a loading icon while searching something asynchronously (which is...
Read more >
Search bar text getting covered due to search icon
Search bar text getting covered due to search icon ... How do i ensure that the text starts after the icon? ... show...
Read more >
ion-searchbar - Ionic Framework
A clear button is displayed when a searchbar has a value or upon entering input in the searchbar's text field. Clicking on the...
Read more >
SearchBar - React Native Elements
SearchBar. SearchBars are used to search or filter items. Use a SearchBar when the number of items directly impacts a user's ability to...
Read more >
Create a React Native search bar from scratch - LogRocket Blog
Learn how to create your own React Native search bar from scratch in this detailed, ... The text input here contains some interesting...
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