Improve menu category selection when scrolling to bottom

Automatically select the last category when the user scrolls to the bottom of the menu list.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jay Sheen
2025-11-03 14:08:45 +09:00
parent 09e6892f1c
commit c6b821a351

View File

@@ -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);