react-native-autocomplete-input icon indicating copy to clipboard operation
react-native-autocomplete-input copied to clipboard

Suggestion list presented behind other elements in the screen

Open duartebotero opened this issue 8 years ago • 5 comments

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 Search for Contact Name of the contact selected{'\n'}{'\n'} Please type the message to be send to the selected contact {'\n'}{'\n'} space to add first message to be send {'\n'}{'\n'} button to send or cancel the message {'\n'}{'\n'} ); } }

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;

duartebotero avatar Jun 08 '18 19:06 duartebotero

When I start typing in the search space and the suggestion list appear, it does behind the other texts presented in the screen. Those texts are coded after the so I don't understand why the autocomplete is shown in the background. Thank for any help

duartebotero avatar Jun 08 '18 19:06 duartebotero

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

SnaiNeR avatar Jun 26 '18 13:06 SnaiNeR

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

flodev avatar Aug 22 '18 14:08 flodev

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 07 '21 01:04 stale[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

stale[bot] avatar Apr 14 '21 21:04 stale[bot]