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.

Multiple Dropdown zIndex doesnt work

See original GitHub issue

Hello

I got 2 dropdowns one above the other. Only in Android i got 2 problems :

  • The first dropdown list go under the closed dropdown of the second list the zindex prop doesnt seems to work on Android and elevation is not recognized as a prop for DropDownPicker
  • The button just under (Touchable opacity) is unreachable (unclickable)

Thanks a lot for support or help provided

<View style={[styles.crenContainer, styles.shadow, { backgroundColor, height: openDate? 520 : openHour? 580 : 280 }]}>
         

        <Text style={[styles.dateText, { color: textColor, fontFamily:'geometria-regular' }]}>
          Sélectionnez la date
        </Text>
        <DropDownPicker
          open={openDate}
          value={selectedDay}
          items={daystobook}
          setOpen={setOpenDate}
          setValue={setSelectedDay}
          setItems={setDaystobook}
          placeholder="Date ..."
          maxHeight={300}
          style={[styles.dropdown, styles.shadow]}
          labelStyle={styles.labeldropdown}
          textStyle={{fontFamily:'geometria-regular', color:"white"}}
          placeholderStyle={styles.labeldropdown}
          zIndex={3000}
          zIndexInverse={1000}
          dropDownContainerStyle={styles.dropdown}
        />
      

        <Text style={[styles.hourText, { color: textColor,  fontFamily:'geometria-regular', marginTop: openDate? 120 : 20 }]}>
          Sélectionnez l'heure 
        </Text>
        <DropDownPicker
          open={openHour}
          value={selectedHour}
          items={hourstobook}
          setOpen={setOpenHour}
          zIndex={2000}
          zIndexInverse={2000}
          setValue={setSelectedHour}
          setItems={setHourstobook}
          textStyle={{fontFamily:'geometria-regular', color:"white"}}
          placeholder="Heure ..."
          maxHeight={300}
          style={[styles.dropdown, styles.shadow]}
          labelStyle={styles.labeldropdown}
          placeholderStyle={styles.labeldropdown}
          dropDownContainerStyle={styles.dropdown}
        />

        {
          !openDate &&
          <View
            style={[
              styles.btnNextContainer,
              styles.shadow,
              { opacity: selectedDay === "" || selectedHour === "" ? 0.5 : 1 },
            ]}
          >
            <TouchableOpacity
              onPress={() => {
                console.log("pressed to go")
                console.log(selectedDay)

                setCrenModalVisible(false)
                setstripeAccIdRestoValue(myintcust.stripeAccId)
                navigation.navigate(goto, {
                  restoId: route.params.restoId,
                  bookingType: bookingType,
                  day: moment.tz(selectedDay, "YYYY-MM-DD", "America/Martinique").format(),
                  hour: selectedHour,
                })
              }}
              style={styles.btnNext}
           //   disabled={selectedDay === "" || selectedHour === ""}
            >
              <Ionicons
                name="arrow-back"
                size={25}
                color="white"
                style={styles.arrow}
              />
            </TouchableOpacity>
          </View>
        }
        {selectedDay !== "" &&
          !loading &&
          hourstobook &&
          hourstobook.length == 0 && (
            <View>
              <Text style={styles.textstrong}>
                Plus d'horaires disponibles ! 🤷🏽‍♂️
              </Text>
           
            </View>
          )}
        {loading && (
          <View style={styles.wrapindicator}>
            <ActivityIndicator size="large" color="#F50F50" />
          </View>
        )}
      </View>

Styles :

crenContainer: {
    position:'absolute',
    bottom: 0,
    left: 0,
    right: 0,
    padding: 20,
    borderRadius: 10
  },
  dropdown: {
    borderColor: "transparent",
    backgroundColor: "#ff5050",
    color:'white',
    fontFamily:'geometria-regular'
  },
  labeldropdown: {
    color: "white",
  //  fontWeight: "bold",
    fontFamily:'geometria-bold'
  },
  dateText: {
    marginBottom: 10,
    fontSize: 14,
    color:'white',
    fontFamily:'geometria-bold'
  },
  hourText: {
    fontFamily:'geometria-bold',
    marginTop: 20,
    marginBottom: 10,
    fontSize: 14,
    color:'white'
  },
  btnNextContainer: {
    position: "absolute",
    bottom: 20,
    right: 20,
    borderRadius: 25,
    color:'white',
    backgroundColor: "#ff5050"
  },
  btnNext: {
    height: 50,
    width: 50,
    color:'white',
    justifyContent: "center",
    alignItems: "center",
  },
 crenText: {
    fontSize: 16,
    padding: 4,
    fontFamily: "geometria-regular",
  },
  shadow: {
    elevation: 4,
    shadowColor: "#000",
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.5,
    shadowRadius: 2,
  },

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hossein-zarecommented, May 25, 2021

Add zIndex to the btnNextContainer style.

btnNextContainer: {
  zIndex: 4000
  ...
}
1reaction
hossein-zarecommented, May 25, 2021

Hello,

elevation is causing the behavior, So take out the styles.shadow from the style property.

style={[styles.dropdown, styles.shadow]}

// to

style={styles.dropdown}
Read more comments on GitHub >

github_iconTop Results From Across the Web

z-index isn't working for my dropdown menu [duplicate]
I have a navigation bar, and the dropdowns are absolutely positioned, but for some reason, they still appear behind all other positioned items, ......
Read more >
4 reasons your z-index isn't working (and how to fix it)
Solution: Move the modal outside of the content parent, and into the main stacking context of the page. The corrected markup would then...
Read more >
Dropdown is behind as z-index doesn't apply #1385 - GitHub
1, only to the current master branch. The problem is that a (not yet released) change is attaching the dropdown element to the...
Read more >
Using z-index - CSS: Cascading Style Sheets - MDN Web Docs
The first article of this guide, Stacking without the z-index property, explains how stacking is arranged by default.
Read more >
Everything you want to know about z-index | Medium
Despite having a z-index of 100000, the dropdown appears below the checkbox. You may be wondering how opacity could determine what comes on...
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