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.

Input will hide behind other inputs

See original GitHub issue

Describe the bug

The input will hide behind other inputs and the list wont show up at all

Reproduction - (required - issue will be closed without this)

Here is the snack link snack

Please provide a FULLY REPRODUCIBLE example.

Click to expand!
  
  import * as React from 'react';
import { View, StyleSheet, TextInput } from 'react-native';
import Constants from 'expo-constants';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';

const GOOGLE_PLACES_API_KEY = ''; // never save your real api key in a snack!

const App = () => {
return (
  <View style={styles.container}>
    <View style={{ height: 100 }}>
      <TextInput
        style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
      />
      <GooglePlacesAutocomplete
        query={{
          key: GOOGLE_PLACES_API_KEY,
          language: 'en', // language of the results
        }}
        onPress={(data, details = null) => console.log(data)}
        onFail={(error) => console.error(error)}
        requestUrl={{
          url:
            'https://cors-anywhere.herokuapp.com/https://maps.googleapis.com/maps/api',
          useOnPlatform: 'web',
        }} // this in only required for use on the web. See https://git.io/JflFv more for details.
        styles={{
          textInputContainer: {
            backgroundColor: 'rgba(0,0,0,0)',
            borderTopWidth: 0,
            borderBottomWidth: 0,
          },
          textInput: {
            marginLeft: 0,
            marginRight: 0,
            height: 38,
            color: '#5d5d5d',
            fontSize: 16,
          },
          predefinedPlacesDescription: {
            color: '#1faadb',
          },
        }}
      />
      <TextInput
        style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
      />
    </View>
  </View>
);
};

const styles = StyleSheet.create({
container: {
  flex: 1,
  justifyContent: 'center',
  paddingTop: Constants.statusBarHeight,
  backgroundColor: '#ecf0f1',
  padding: 8,
},
});

export default App;

Additional context

  • Library Version: latest

  • React Native Version: 0.62

  • iOS

  • Android

  • Web

If you are using expo please indicate here:

  • I am using expo

Add any other context about the problem here, screenshots etc https://i.imgur.com/zeFDWKL.png

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
arulp3commented, Jan 11, 2022

There is a simple solution to this, Jus create a separate view and put the Googleautocomplete tag inside the view.

0reactions
bell-stevencommented, Aug 11, 2020

First off, thank you for taking the time to reproduce this and dig into it.

Just so other people reading this know, the correct way to solve this (currently) is to set the zIndex in the container style and position: absolute or fixed in the listView style.

Example
import * as React from 'react';
import { View, StyleSheet, TextInput, TouchableOpacity } from 'react-native';
import Constants from 'expo-constants';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';

const GOOGLE_PLACES_API_KEY = ''; // never save your real api key in a snack!

const App = () => {
  return (
    <View style={styles.container}>
      <View>
        <TextInput style={{ borderWidth: 1, height: 40 }} />
        <GooglePlacesAutocomplete
          query={{
            key: GOOGLE_PLACES_API_KEY,
            language: 'en', // language of the results
          }}
          onPress={(data, details = null) => console.log(data)}
          onFail={(error) => console.error(error)}
          requestUrl={{
            url:
              'https://cors-anywhere.herokuapp.com/https://maps.googleapis.com/maps/api',
            useOnPlatform: 'web',
          }} // this in only required for use on the web. See https://git.io/JflFv more for details.
          styles={{
            container: {
              zIndex: 99,
            },
            listView: {
              backgroundColor: 'white',
              position: 'absolute',
              marginTop: 40,
            },
          }}
        />
        <TouchableOpacity onPress={() => alert('taco')}>
          <TextInput
            placeholder="Press here and you wil get an alert"
            style={{ borderWidth: 1, borderColor: 'red', height: 40 }}
          />
        </TouchableOpacity>
        <View style={{ height: 30, backgroundColor: 'orange' }} />
        <TextInput style={{ borderWidth: 1, height: 40 }} />
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
});

export default App;

Well then first off InputComp is not documented anywhere, in this library, or the docs for TextInput, its also not in the d.ts file

You are right. Feel free to put in a PR

You can’t tell me that that is expected behavior…

If you take out all the styles it would have fit in the box.

If you feel there is a better approach to this (or anything), I would be more than happy to discuss and/or review/merge a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

<input type="hidden"> - HTML: HyperText Markup Language
Hidden inputs are completely invisible in the rendered page, and there is no way to make it visible in the page's content. Note:...
Read more >
html - inputs getting hidden behind image - Stack Overflow
Problem is the inputs are placed "absolute" over top of the images and in IE (of course IE!!) the form inputs arent realy...
Read more >
HTML input type="hidden" - W3Schools
The <input type="hidden"> defines a hidden input field. A hidden field lets web developers include data that cannot be seen or modified by...
Read more >
Hide input field when second input field is in focus
When the user clicks on one input (Search, for example), I want the second (Subscribe) to disappear so the other input can grow...
Read more >
How to Hide Form Fields Based Upon User Selection - Solodev
Hiding certain form fields until a user triggers them with a previous answer can be a simple way to withhold certain questions until...
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