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.

Not able to select drop down elements that are outside of parent container view?

See original GitHub issue

I tried playing around with the zIndex of the parent container as well as the various style props for the autocomplete. All items that flow outside of the parent container are not selectable and the view underneath is touched.

I am using it not as a search form but as a custom dropdown component. I figure the issue is the same regardless.

I have wrapped the autocomplete in an absolute positioned view as per the docs. Does anyone else experience this?

My component below is inside a <View> that is positioned absolutely with a fixed height and the dropdown elements hang outside of the parent view.

  <View style={{minHeight: 35, flex: 1}}>
      <View style={styles.autocompleteContainer}>
        <Autocomplete
          data={data}
          listStyle={styles.listStyles}
          inputContainerStyle={styles.inputContainer}
          onFocus={onFocus}
          keyExtractor={item => item}
          returnKeyType={'next'}
          hideResults={hideResults}
          renderTextInput={() => (
            <TouchableOpacity
              style={styles.textInputItem}
              onPress={() => setHideResults(!hideResults)}>
              <Text style={styles.textInputItemText}>{currentValue}</Text>
            </TouchableOpacity>
          )}
          renderItem={({item}) => (
            <TouchableOpacity onPress={onSelect}>
              <Text style={styles.listTextStyle}>{item}</Text>
            </TouchableOpacity>
          )}
        />
      </View>
    </View>
const styles = {
  autocompleteContainer: {
    flex: 1,
    left: 0,
    position: 'absolute',
    borderRadius: 2,
    right: 0,
    top: 0,
  },
  inputContainer: {
    backgroundColor: 'red',
    borderWidth: 0,
  },
  listStyles: {
    backgroundColor: 'blue',
    borderWidth: 0,
    margin: 0,
  },
  listTextStyle: {
    color: 'white',
    width: '100%',
    paddingVertical: 8,
    paddingLeft: 20,
  },
  textInputItem: {
    height: 35,
    justifyContent: 'center',
    paddingLeft: 20,
  },
  textInputItemText: {
    color: 'white',
  },
};

Issue Analytics

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

github_iconTop GitHub Comments

10reactions
tayloraleachcommented, May 29, 2020

@changyu2hao Hey so I was able to get my list items to register touch by importing from here instead of the regular react-native:

import {TouchableOpacity} from 'react-native-gesture-handler';

I also went into the actual node_modules directory and inside index.js for this package, doing the same thing and moving that import for the root <FlatList> component to the gesture handler, and now scroll works for me with my absolute positioned component on both Android and iOS!!! 😃

0reactions
AustinWoodcommented, Nov 15, 2021

@changyu2hao Hey so I was able to get my list items to register touch by importing from here instead of the regular react-native:

import {TouchableOpacity} from 'react-native-gesture-handler';

I also went into the actual node_modules directory and inside index.js for this package, doing the same thing and moving that import for the root <FlatList> component to the gesture handler, and now scroll works for me with my absolute positioned component on both Android and iOS!!! 😃

This is exact solution in Android for scrolling issue. I think it needs to be pinned on issues tab

after patching node_modules, add this step in package.json.

"postinstall": "npx patch-package"

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to show a dropdown menu outside a parent element with ...
The only solution I found online and made sense to me, is to wrap the container to div with relative positioning and make...
Read more >
dropdowns not going outside of bounding containers #404
It seems that dropdowns seem to render only within the parent container that the select is in, instead of being on top of...
Read more >
<select>: The HTML Select element - HTML - MDN Web Docs
Holding down the Ctrl key then using the Up and Down cursor keys to change the "focused" select option, i.e. the one that...
Read more >
Create drop-down component - MATLAB uidropdown
This MATLAB function creates a drop-down in a new figure window and returns the DropDown object.
Read more >
Making Child Element Visible When Outside Parent Element ...
Anyway, here our main problem is that the relative parent is additionally the overflow: hidden one. Well, if we tend to merely move...
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