fixed the dropdown

This commit is contained in:
daniel31x13
2023-10-28 12:50:11 -04:00
parent db47a2a142
commit 2856e23a4a
11 changed files with 120 additions and 46 deletions
+11 -1
View File
@@ -5,6 +5,7 @@ type Props = {
onClickOutside: Function;
className?: string;
style?: React.CSSProperties;
onMount?: (rect: DOMRect) => void;
};
function useOutsideAlerter(
@@ -32,10 +33,19 @@ export default function ClickAwayHandler({
onClickOutside,
className,
style,
onMount,
}: Props) {
const wrapperRef = useRef(null);
const wrapperRef = useRef<HTMLDivElement | null>(null);
useOutsideAlerter(wrapperRef, onClickOutside);
useEffect(() => {
if (wrapperRef.current && onMount) {
const rect = wrapperRef.current.getBoundingClientRect();
onMount(rect); // Pass the bounding rectangle to the parent
}
}, []);
return (
<div ref={wrapperRef} className={className} style={style}>
{children}