byteburgers / react-native-autocomplete-input

Pure javascript autocomplete input for react-native
https://byteburgers.com/autocomplete
MIT License
818 stars 255 forks source link

iOS dropdown presents itself behind other components #272

Open ApluUalberta opened 9 months ago

ApluUalberta commented 9 months ago

Though this component works well on Android, iOS applications get this weird behaviour:

Untitled design (6)

The specific Front-end Tech stack that I use is React Native Expo, and the error presents itself on dev and Internal Builds. The display of the menu can be fixed as a result of zIndex: -1 and position: "absolute" in the parent View component, however this is far from adequate as this affects the component's positioning relative to other components. It is the exact same issue as here: Issue 212

Please provide an adequate solution for this on iOS that decouples it from other components. Thanks

sevastijan commented 9 months ago

In my case, it was enough to set the parent's zIndex to a higher value than the following elements. Try it at your case maybe it will work too 😄

ApluUalberta commented 9 months ago

In my case, it was enough to set the parent's zIndex to a higher value than the following elements. Try it at your case maybe it will work too 😄

I couldn't manage to get ti to work. Do you mind sharing an example?

ApluUalberta commented 9 months ago

In my case, it was enough to set the parent's zIndex to a higher value than the following elements. Try it at your case maybe it will work too 😄

I was able to resolve this issue. As it turns out, this is the solution, but this requires a nuanced understanding of component elevation and how your app styling is structured.

Here is my example:

const ModalContents = () => { ... return (

...
  </View>

); }


In order to solve it in my case, I needed to somehow communicate between the "base" component and the autocomplete its elevation without losing its elevation within the nesting of it in views. Though this is very specific to my use-case. Perhaps the best way this can help someone else is to say i fixed it by playing around.

Hope this helps someone!