diff --git a/.changeset/few-goats-give.md b/.changeset/few-goats-give.md new file mode 100644 index 00000000..da88bb24 --- /dev/null +++ b/.changeset/few-goats-give.md @@ -0,0 +1,5 @@ +--- +'@sopt-makers/ui': patch +--- + +fix(ui) Select Menu 렌더링 위치 수정 diff --git a/packages/ui/Input/Select.tsx b/packages/ui/Input/Select.tsx index ac15e253..7fbcfc5d 100644 --- a/packages/ui/Input/Select.tsx +++ b/packages/ui/Input/Select.tsx @@ -193,11 +193,22 @@ function SelectMenu({ children, className }: SelectMenuProps) { return null; } - const top = `${buttonRect.top + buttonRect.height}px`; - const left = `${buttonRect.left}px`; + const maxHeight = calcMaxHeight(); + + const scrollTop = window.scrollY || document.documentElement.scrollTop; + const scrollLeft = window.scrollX || document.documentElement.scrollLeft; + const spaceBelow = window.innerHeight - buttonRect.bottom; + const hasSpaceBelow = spaceBelow >= maxHeight; + + const top = hasSpaceBelow + ? `${buttonRect.top + buttonRect.height + scrollTop}px` + : `${buttonRect.top + scrollTop - maxHeight}px`; + const left = `${buttonRect.left + scrollLeft}px`; + + const animationClass = hasSpaceBelow ? S.optionListAnimation.down : S.optionListAnimation.up; return createPortal( -