diff --git a/src/shared/ui/menu/index.tsx b/src/shared/ui/menu/index.tsx index 643c996..6679fd6 100644 --- a/src/shared/ui/menu/index.tsx +++ b/src/shared/ui/menu/index.tsx @@ -218,8 +218,22 @@ export const Menu = ({ const menuListScroll = () => { if (isButtonScrolling.current) return; - const scrollTop = scrollRef.current?.scrollTop || 0; - const currentIndex = getCurrentCategoryIndex(scrollTop); + if (!scrollRef.current) return; + + const scrollTop = scrollRef.current.scrollTop; + const scrollHeight = scrollRef.current.scrollHeight; + const clientHeight = scrollRef.current.clientHeight; + + // 스크롤이 맨 밑에 도달했는지 확인 (약간의 오차 허용) + const isAtBottom = scrollHeight - scrollTop - clientHeight < 1; + + let currentIndex: number; + if (isAtBottom) { + // 맨 밑이면 마지막 카테고리 선택 + currentIndex = buttonRefs.current.length - 1; + } else { + currentIndex = getCurrentCategoryIndex(scrollTop); + } if (currentIndex !== shortBtnIdx) { setShortBtnIdx(currentIndex);