SearchBar's TextInput gets cleared with showLoadingIcon prop.
See original GitHub issueDescription
- Explain what you did
Tried to use the SearchBar component with the
showLoadingIcon
prop. - What you expected to happen
ActivityIndicator
should show and hide according to the value provided. - What actually happens
ActivityIndicator
works as expected, but theTextInput
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:
- Created 6 years ago
- Comments:8
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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 eachrender
. Check this example ✌️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?