Skip to content

Commit

Permalink
Merge pull request #27035 from shubham1206agra/fix-25595
Browse files Browse the repository at this point in the history
Fixed no result found after selecting a address from the drop-down menu
  • Loading branch information
AndrewGable authored Oct 5, 2023
2 parents 93bfbc5 + 7c3ed3a commit 23d5953
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"react-native-fast-image": "^8.6.3",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "2.12.0",
"react-native-google-places-autocomplete": "git+https://github.com/Expensify/react-native-google-places-autocomplete.git#c8c2a873335df19081056a5667f5c109583882e1",
"react-native-google-places-autocomplete": "2.5.5",
"react-native-haptic-feedback": "^1.13.0",
"react-native-image-pan-zoom": "^2.1.12",
"react-native-image-picker": "^5.1.0",
Expand Down
17 changes: 14 additions & 3 deletions src/components/AddressSearch/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'underscore';
import React, {useMemo, useRef, useState} from 'react';
import PropTypes from 'prop-types';
import {LogBox, ScrollView, View, Text} from 'react-native';
import {LogBox, ScrollView, View, Text, ActivityIndicator} from 'react-native';
import {GooglePlacesAutocomplete} from 'react-native-google-places-autocomplete';
import lodashGet from 'lodash/get';
import compose from '../../libs/compose';
Expand Down Expand Up @@ -134,6 +134,7 @@ const defaultProps = {
// Reference: https://github.com/FaridSafi/react-native-google-places-autocomplete/issues/609#issuecomment-886133839
function AddressSearch(props) {
const [displayListViewBorder, setDisplayListViewBorder] = useState(false);
const [isTyping, setIsTyping] = useState(false);
const containerRef = useRef();
const query = useMemo(
() => ({
Expand Down Expand Up @@ -287,11 +288,19 @@ function AddressSearch(props) {
suppressDefaultStyles
enablePoweredByContainer={false}
predefinedPlaces={props.predefinedPlaces}
ListEmptyComponent={
props.network.isOffline ? null : (
listEmptyComponent={
props.network.isOffline || !isTyping ? null : (
<Text style={[styles.textLabel, styles.colorMuted, styles.pv4, styles.ph3, styles.overflowAuto]}>{props.translate('common.noResultsFound')}</Text>
)
}
listLoaderComponent={
<View style={[styles.pv4]}>
<ActivityIndicator
color={themeColors.spinner}
size="small"
/>
</View>
}
renderHeaderComponent={() =>
!props.value &&
props.predefinedPlaces && (
Expand All @@ -300,6 +309,7 @@ function AddressSearch(props) {
}
onPress={(data, details) => {
saveLocationDetails(data, details);
setIsTyping(false);

// After we select an option, we set displayListViewBorder to false to prevent UI flickering
setDisplayListViewBorder(false);
Expand Down Expand Up @@ -338,6 +348,7 @@ function AddressSearch(props) {
},
autoComplete: 'off',
onInputChange: (text) => {
setIsTyping(true);
if (props.inputID) {
props.onInputChange(text);
} else {
Expand Down

0 comments on commit 23d5953

Please sign in to comment.