Skip to content

Dropdown List Appears Behind Modal and Cannot Be Selected #130

Open
@lucasAzS

Description

@lucasAzS

I am encountering an issue when using the react-native-autocomplete-dropdown library within a React Native modal. The dropdown list appears behind the modal and is not interactable. Additionally, when I attempt to modify the styles and positioning, the dropdown list either does not appear or remains below other elements, making it unusable.

Code Example:

import React, { useState } from 'react';
import { StyleSheet, Text, View, Modal, Button } from 'react-native';
import { AutocompleteDropdown } from 'react-native-autocomplete-dropdown';

const data = [
    { id: '77772', title: 'Isabel ' },
    { id: '77773', title: 'Elson ' },
    { id: '77774', title: 'Rodrigo ' },
    { id: '77775', title: 'Diogo ' },
    { id: '77792', title: 'Filipa ' },
    { id: '80830', title: 'Lucas' },
    { id: '99998', title: 'AutomatedTests' },
    { id: '99999', title: 'AutomatedTests' },
    { id: '121212', title: 'Karina ' },
    { id: '233217', title: 'Joaquim ' },
    { id: '999999', title: 'Processamento ' },
];

export const SandBoxMainScreen = React.memo(() => {
    const [modalVisible, setModalVisible] = useState(false);

    return (
        <View style={styles.container}>
            <Text>SandBox</Text>
            <Button title="Show Modal" onPress={() => setModalVisible(true)} />
            <Modal
                animationType="slide"
                transparent={true}
                visible={modalVisible}
                onRequestClose={() => {
                    setModalVisible(!modalVisible);
                }}
            >
                <View style={styles.modalView}>
                    <Text style={styles.modalText}>Hello, this is a modal!</Text>
                    <Button title="Close Modal" onPress={() => setModalVisible(false)} />

                    <AutocompleteDropdown dataSet={data} inputContainerStyle={styles.input} />
                </View>
            </Modal>
        </View>
    );
});

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#fff',
        alignItems: 'center',
        justifyContent: 'center',
    },
    modalView: {
        backgroundColor: 'white',
        borderRadius: 20,
        padding: 20,
        alignItems: 'center',
        shadowColor: '#000',
        shadowOffset: {
            width: 0,
            height: 2,
        },
        shadowOpacity: 0.25,
        shadowRadius: 4,
        elevation: 5,
        bottom: 0,
        left: 0,
        right: 0,
        zIndex: 1000,
        position: 'absolute',
        width: '100%',
        height: '50%',
    },
    modalText: {
        marginBottom: 15,
        textAlign: 'center',
    },
    input: {
        width: '100%',
        height: 40,
        padding: 10,
        borderWidth: 1,
        borderColor: 'black',
        marginBottom: 10,
        borderRadius: 5,
        backgroundColor: 'white',
    },
});

Screenshots
screenshot-1718056091668

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions