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

zIndex not set correclty

Open Snotax opened this issue 2 years ago • 1 comments

Hi, in your web example, the dropdown is hidden behind other components that are below it in the DOM hirarchy. Are you aware of this issue ?

image

Snotax avatar Aug 29 '22 09:08 Snotax

I had the same problem. I solve it adding:

suggestionsListContainerStyle={{ position: 'relative', top: 0 }}

saralorena92 avatar Sep 30 '22 13:09 saralorena92

I was having this same issue but I'm not even sure what resolved it, setting the style={{ zIndex: 1 }} of the View wrapping my AutocompleteDropdown actually did end up fixing it. The examples at the bottom of the readme with the style set with zIndex like Platform.select({ ios: { zIndex: 10 } }) are only setting it for ios, setting mine for web worked.

<View style={[{ marginBottom: 20 }, Platform.select({ ios: { zIndex: 1 }, web: { zIndex: 1 } })]}>
            <Text>Header</Text>
            <AutocompleteDropdown
              dataSet={[
                { id: '1', title: 'Alpha' },
                { id: '2', title: 'Beta' },
                { id: '3', title: 'Gamma' },
              ]}
              />
          </View>

Setting the container style for me moved the form fields below because of the position set to relative.

jomann09 avatar Nov 05 '22 21:11 jomann09

I had the same problem. I solve it adding:

suggestionsListContainerStyle={{ position: 'relative', top: 0 }}

While this somewhat solves it, it is still making the suggestionbox relative meaning it "takes up space" in the page and pushing all other elements down.. Anyone knows how to achieve a floating suggestionbox-style? (intended behaviour)?

eylonxx avatar Dec 28 '22 14:12 eylonxx

I had the same problem. I solve it adding: suggestionsListContainerStyle={{ position: 'relative', top: 0 }}

While this somewhat solves it, it is still making the suggestionbox relative meaning it "takes up space" in the page and pushing all other elements down.. Anyone knows how to achieve a floating suggestionbox-style? (intended behaviour)?

same problem

Marcuspo avatar Jan 02 '23 01:01 Marcuspo

The right solution is here Wrap the Autocomplete with View and set zIndex to 10 or higher

<View
            style={[styles.section, Platform.select({ ios: { zIndex: 10 } })]}>
            <Text style={styles.sectionTitle}>First</Text>
            <AutocompleteDropdown
              dataSet={[
                { id: '1', title: 'Alpha' },
                { id: '2', title: 'Beta' },
                { id: '3', title: 'Gamma' },
              ]}
            />
          </View>
          <View
            style={[styles.section, Platform.select({ ios: { zIndex: 9 } })]}>
            <Text style={styles.sectionTitle}>Second</Text>
            <AutocompleteDropdown
              dataSet={[
                { id: '1', title: 'Alpha' },
                { id: '2', title: 'Beta' },
                { id: '3', title: 'Gamma' },
              ]}
            />
          </View>

lac_zagh

mustapha1509 avatar Jan 23 '23 10:01 mustapha1509

The right solution is here Wrap the Autocomplete with View and set zIndex to 10 or higher

<View
            style={[styles.section, Platform.select({ ios: { zIndex: 10 } })]}>
            <Text style={styles.sectionTitle}>First</Text>
            <AutocompleteDropdown
              dataSet={[
                { id: '1', title: 'Alpha' },
                { id: '2', title: 'Beta' },
                { id: '3', title: 'Gamma' },
              ]}
            />
          </View>
          <View
            style={[styles.section, Platform.select({ ios: { zIndex: 9 } })]}>
            <Text style={styles.sectionTitle}>Second</Text>
            <AutocompleteDropdown
              dataSet={[
                { id: '1', title: 'Alpha' },
                { id: '2', title: 'Beta' },
                { id: '3', title: 'Gamma' },
              ]}
            />
          </View>

This didn't work for me at first, but i also had an additional outer View around all my Autocomplete fields (that all have their own View around for style purposes). Once adding zIndex: 1 in that said outer View around all the Autocomplete fields, and removing the zIndex from the Autocomplete fields Views, it worked for me (on Android at least, haven't tried on iOS yet).

<View style={{zIndex: 1}}>
    </View //another style without zIndex>
      <AutocompleteInput
      dataSet={[
          { id: '1', title: 'Alpha' },                 
          { id: '2', title: 'Beta' },          
          { id: '3', title: 'Gamma' },             
       ]}
      />
    </View>
    <View //another style without zIndex>
      <AutocompleteInput
        dataSet={[
            { id: '1', title: 'Alpha' },                 
            { id: '2', title: 'Beta' },          
            { id: '3', title: 'Gamma' },             
         ]}
    />
    </View>
 </View>

NadiaMit avatar Jan 26 '23 08:01 NadiaMit

I have the problem now in android

kasaiee avatar May 30 '23 08:05 kasaiee

please try v3

onmotion avatar May 30 '23 08:05 onmotion