fix: review

This commit is contained in:
Apoorv Mishra committed 2024-07-03 08:18:30 +05:30
1 parent d48615d369
commit cff72cb2e1
2 files changed
+6 -6

No files matched your search

@@ -70,7 +70,7 @@ export const Suggestions = observer(
const containerRef = React.useRef<HTMLDivElement | null>(null);
const maxHeight = useMaxHeight({
elementRef: containerRef,
maxViewportHeight: 70,
maxViewportPercentage: 70,
});
const fetchUsersByQuery = useThrottledCallback(
+5 -5
View File
@@ -4,11 +4,11 @@ import useWindowSize from "./useWindowSize";
const useMaxHeight = ({
elementRef,
maxViewportHeight = 90,
margin = 8,
maxViewportPercentage = 90,
margin = 16,
}: {
/** The maximum height of the element as a percentage of the viewport. */
maxViewportHeight?: number;
maxViewportPercentage?: number;
/** A ref pointing to the element. */
elementRef?: React.RefObject<HTMLElement | null>;
/** The margin to apply to the positioning. */
@@ -20,7 +20,7 @@ const useMaxHeight = ({
React.useLayoutEffect(() => {
if (!isMobile && elementRef?.current) {
const mxHeight = (windowHeight / 100) * maxViewportHeight;
const mxHeight = (windowHeight / 100) * maxViewportPercentage;
setMaxHeight(
Math.min(
@@ -35,7 +35,7 @@ const useMaxHeight = ({
} else {
setMaxHeight(0);
}
}, [elementRef, windowHeight, margin, isMobile, maxViewportHeight]);
}, [elementRef, windowHeight, margin, isMobile, maxViewportPercentage]);
return maxHeight;
};