-
-
Notifications
You must be signed in to change notification settings - Fork 855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onPress not working on android #940
Comments
Facing this issue as well. Any resolutions yet? |
index 99a2a13..6640f00 100644
--- a/node_modules/react-native-google-places-autocomplete/GooglePlacesAutocomplete.js
+++ b/node_modules/react-native-google-places-autocomplete/GooglePlacesAutocomplete.js
@@ -13,7 +13,6 @@ import React, {
} from 'react';
import {
ActivityIndicator,
- FlatList,
Image,
Keyboard,
Platform,
@@ -22,8 +21,10 @@ import {
StyleSheet,
Text,
TextInput,
+ TouchableOpacity,
View,
} from 'react-native';
+import { FlatList } from 'react-native-gesture-handler';
const defaultStyles = {
container: {
@@ -258,6 +259,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
};
const _onPress = (rowData) => {
+ console.log('pressed')
if (rowData.isPredefinedPlace !== true && props.fetchDetails === true) {
if (rowData.isLoading === true) {
// already requesting
@@ -645,19 +647,11 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
return null;
};
- const _renderRow = (rowData = {}, index) => {
+ const _renderRow =useCallback((rowData = {}, index) => {
+ console.log('rendered')
return (
- <ScrollView
- contentContainerStyle={
- props.isRowScrollable ? { minWidth: '100%' } : { width: '100%' }
- }
- scrollEnabled={props.isRowScrollable}
- keyboardShouldPersistTaps={props.keyboardShouldPersistTaps}
- horizontal={true}
- showsHorizontalScrollIndicator={false}
- showsVerticalScrollIndicator={false}
- >
<Pressable
+ key={Math.random().toString(36)}
style={({ hovered, pressed }) => [
props.isRowScrollable ? { minWidth: '100%' } : { width: '100%' },
{
@@ -682,9 +676,9 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
{_renderRowData(rowData, index)}
</View>
</Pressable>
- </ScrollView>
);
- };
+ },[props]);
+
const _renderSeparator = (sectionID, rowID) => {
if (rowID === dataSource.length - 1) {
@@ -785,46 +779,24 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
}
};
- const _getFlatList = () => {
- const keyGenerator = () => Math.random().toString(36).substr(2, 10);
+ const _getFlatList =useCallback( () => {
if (
- supportedPlatform() &&
- (stateText !== '' ||
- props.predefinedPlaces.length > 0 ||
- props.currentLocation === true) &&
+ stateText !== '' &&
listViewDisplayed === true
) {
return (
- <FlatList
- nativeID='result-list-id'
- scrollEnabled={!props.disableScroll}
- style={[
- props.suppressDefaultStyles ? {} : defaultStyles.listView,
- props.styles.listView,
- ]}
- data={dataSource}
- keyExtractor={keyGenerator}
- extraData={[dataSource, props]}
- ItemSeparatorComponent={_renderSeparator}
- renderItem={({ item, index }) => _renderRow(item, index)}
- ListEmptyComponent={
- listLoaderDisplayed
- ? props.listLoaderComponent
- : stateText.length > props.minLength && props.listEmptyComponent
- }
- ListHeaderComponent={
- props.renderHeaderComponent &&
- props.renderHeaderComponent(stateText)
- }
- ListFooterComponent={_renderPoweredLogo}
- {...props}
- />
+ <View style={{zIndex:0,}} >
+ {[...dataSource].slice(0,5).map((item,index)=>{
+ return _renderRow(item, index)
+ })}
+ </View>
+
);
}
return null;
- };
+ },[dataSource]);
let {
onFocus,
@@ -835,6 +807,8 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
...userProps
} = props.textInputProps;
const TextInputComp = InputComp || TextInput;
+ console.log('rendered')
+
return (
<View
style={[
@@ -882,9 +856,9 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
{_renderRightButton()}
</View>
)}
- {props.inbetweenCompo}
+ {/* {props.inbetweenCompo} */}
{_getFlatList()}
- {props.children}
+ {/* {props.children} */}
</View>
);
}); @juzerdhinoj-dimiour you can use this patch file and the issue will be resolved. I replaced Flatlist with map and it worked. Still not get why onPress was not working inside Flatlist |
Will this disrupt the currently working iOS functionality?
|
No, it will not reflect the ios. |
@jahanzaib5244 Instead of the change list, can you please share the actual file? It will be a better reference point. |
|
@jahanzaib5244 the patch works but it affects the onPress functionality. After some testing, I found that original code seems to work as well when you turn the keyboard off in Android emulator. Now I need to explore what is causing the conflict with the keyboard popup. |
have you tried adding the <ScrollView keyboardShouldPersistTaps="handled">
<View keyboardShouldPersistTaps="handled" >
<GooglePlacesAutocomplete
// your everything
/>
</View>
</ScrollView> |
Same issue,
|
@Jheysson You can use this Patch file code
const defaultStyles = { const _onPress = (rowData) => {
@@ -682,9 +676,9 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
const _renderSeparator = (sectionID, rowID) => {
});` |
this works for me thanks a lot @jahanzaib5244 but why there is problem still exist? Why not fixed do you know? I think i got the problem cause of i wrap the google-places-autocomplete with modal so onPress is not working fine but if you add |
@jahanzaib5244 i have the same issue working on ios but not andriod |
Same issue |
You could add |
Thanks, this was the simple and obvious (in retrospect) issue. All fixed! |
I have the same issue with keepResultsAfterBlur having to tap away the keyboard and then select with the onPress
|
onPress not working on android
i am using a map and GooglePlacesAutocomplete input on ios it is working perfectly but on android i am unable to pick the location .
Please provide a FULLY REPRODUCIBLE example.
Click to expand!
Please remember to remove you google API key from the code you provide here
Additional context
Add any other context about the problem here, screenshots etc
The text was updated successfully, but these errors were encountered: