I am encountering an issue with a custom dropdown component that I have created dynamically within a form. The problem arises when the dropdown menu appears after a user selects an option from another dropdown menu, which is essentially the same component being reused. In this scenario, the dynamically appearing dropdown menu gets hidden below other elements on the form, making it impossible for the user to see the available options. Strangely enough, everything works perfectly fine when the component is not loaded dynamically beforehand in the form. Attached are some screenshots for reference. Any insights on why this might be happening and how to rectify it?
https://i.sstatic.net/7c1ia.png
Here is the code snippet: Please note that this custom component enables users to input text while also selecting options from a dropdown menu that filters as they type. The parent component is referred to as the "container" with its style specified as "containerstyle". All other elements within it are considered children. The dropdown menu is positioned absolutely, while the parent container is positioned relatively:
const containerstyle={
position: "relative",
top: 0,
left: 0,
get display(){if(layout=="stacked"){return "block"}else{return "flex"}},
width: "100%",
height: height || 58,
}
const inputStyle ={
cursor: "pointer",
fontSize: valueSize || 16,
fontWeight: valueBold || "normal",
color: valueColor || "black",
backgroundColor: fill || "white",
outline: "none",
width: width || "100%",
height: height || "100%",
}
const labelStyle ={
fontSize: labelSize || inputStyle.fontSize-3,
fontWeight: labelBold || "normal",
color: labelColor || "rgb(145, 145, 145)",
padding: padding || 5,
marginRight: 10,
}
const dropDownStyle = {
display: dropDownDisplay,
position: "absolute",
top: containerstyle.top+containerstyle.height,
left: inputStyle.left,
width: "100%",
minHeight: 300,
maxHeight: 300,
overflowY: "auto",
overflowX: "hidden",
padding: padding || 5,
display: dropDownDisplay,
backgroundColor: dropDownFill || "rgba(255,255,255,0.95)",
boxShadow: "5px 5px 5px lightgray",
border: "1px solid lightgray",
borderRadius: "0px 0px 5px 10px",
color: valueColor || "black",
zIndex: 999999
}
const optionsStyle = {
display: "block",
width: "100%",
cursor: "pointer",
fontSize: inputStyle.fontSize,
fontWeight: optionWeight || "normal",
padding: padding || 5,
color: optionColor || "black",
backgroundColor: fill || "rgb(255,255,255,0)",
}