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.

Suggestion list presented behind other elements in the screen

See original GitHub issue

import React, { Component } from ‘react’; import { Text, StyleSheet, View, TouchableOpacity, Platform } from ‘react-native’;

import Autocomplete from ‘react-native-autocomplete-input’;

class NewScreen extends Component {

constructor(props) { this.state = { contacts: [‘Andres’, ‘Antonio’, ‘Armando’, ‘Alberto’, ‘Roberto’], query: ‘’, }; }

findContact(query) { if (query === ‘’) { return []; } const { contacts } = this.state; const regex = new RegExp(${query.trim()}, ‘i’); const conts = contacts.filter(contact => contact.search(regex) >= 0); console.log(‘CONTACTOS’, contacts); return conts; }

render() { const { query, selected } = this.state; const contacts = this.findContact(query);

return (

        <View>
          <Text>Search for Contact</Text>
          <View>
            <Autocomplete
              autoCapitalize="none"
              autoCorrect={false}
              containerStyle={Platform.OS === 'android' ? 
                   styles.androidAutocompleteContainer : styles.iosAutocompleteContainer}
              inputContainerStyle={styles.input}
              listContainerStyle={styles.listContainer}
              listStyle={styles.list}
              data={contacts}
              defaultValue={selected || query}
              onChangeText={text => this.setState({ query: text })}
              placeholder="Enter contact name"
              renderItem={item => (
                <TouchableOpacity
                  onPress={
                    () => {
                      this.setState({
                        query: '',
                        selected: item
                      });
                    }
                  }
                >
                  <Text>{item}</Text>
                </TouchableOpacity>
              )}
            />
          </View>

//random text that is also in the screen <Text>Search for Contact</Text> <Text>Name of the contact selected{‘\n’}{‘\n’}</Text> <Text> Please type the message to be send to the selected contact {‘\n’}{‘\n’}</Text> <Text> space to add first message to be send {‘\n’}{‘\n’}</Text> <Text> button to send or cancel the message {‘\n’}{‘\n’}</Text> </View> ); } }

const styles = StyleSheet.create({ androidAutocompleteContainer: { flex: 1, left: 0, position: ‘absolute’, right: 0, top: 0, zIndex: 1, width: 200, margin: 10, backgroundColor: ‘white’, borderColor: ‘red’, borderWidth: 2 }, iosAutocompleteContainer: { width: 200, margin: 10, backgroundColor: ‘white’, borderColor: ‘red’, borderWidth: 2 }, //tried different color to see if any background would cover the text list: { backgroundColor: ‘red’, }, listContainer: { backgroundColor: ‘green’, }, input: { backgroundColor: ‘blue’, } });

export default NewScreen;

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

20reactions
flodevcommented, Aug 22, 2018

listStyle={{position: 'relative'}}
I’m using this workaround since overlapping doesn’t work on android either.

6reactions
SnaiNeRcommented, Jun 27, 2018

add “zIndex” to wrapping Autocomplete View: <View style={{ zIndex: 999 }}>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap Dropdown appears behind other elements
I have a template that mix bootstrap accordion and dropdown, the problem is that dropdown appears behind the next question card ...
Read more >
Change the order in which stacked objects, placeholders, or ...
If an object is hidden behind other objects, select Home > Select > Selection Pane. In the Selection Pane, drag an item to...
Read more >
Positioning - Learn web development | MDN
Positioning makes such layout work possible. There are a number of different types of positioning that you can put into effect on HTML...
Read more >
display | CSS-Tricks
Every element on a web page is a rectangular box. The display property in CSS determines just how that rectangular box behaves.
Read more >
CSS Display Module Level 3 - W3C
Abstract. This module describes how the CSS formatting box tree is generated from the document element tree and defines the display property ...
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