fix: Various improvements to select input, closes #4528
This commit is contained in:
@@ -4,25 +4,24 @@ import useWindowSize from "~/hooks/useWindowSize";
|
||||
|
||||
const useMenuHeight = (
|
||||
visible: void | boolean,
|
||||
unstable_disclosureRef?: React.RefObject<HTMLElement | null>
|
||||
unstable_disclosureRef?: React.RefObject<HTMLElement | null>,
|
||||
margin = 8
|
||||
) => {
|
||||
const [maxHeight, setMaxHeight] = React.useState<number | undefined>();
|
||||
const isMobile = useMobile();
|
||||
const { height: windowHeight } = useWindowSize();
|
||||
|
||||
React.useEffect(() => {
|
||||
const padding = 8;
|
||||
|
||||
if (visible && !isMobile) {
|
||||
setMaxHeight(
|
||||
unstable_disclosureRef?.current
|
||||
? windowHeight -
|
||||
unstable_disclosureRef.current.getBoundingClientRect().bottom -
|
||||
padding
|
||||
margin
|
||||
: undefined
|
||||
);
|
||||
}
|
||||
}, [visible, unstable_disclosureRef, windowHeight, isMobile]);
|
||||
}, [visible, unstable_disclosureRef, windowHeight, margin, isMobile]);
|
||||
return maxHeight;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user