fix: prefer direction with more available space for dropdown

Compare space above vs below the trigger and open toward whichever
side has more room. Prevents flipping upward when the menu would
overflow even more in that direction.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jin Yi
2026-03-25 13:43:45 +09:00
parent 7b5a49975f
commit 0def631c52

View File

@@ -146,7 +146,9 @@ function toggleDropdown() {
if (disabled) return
if (!isOpen.value && triggerRef.value) {
const rect = triggerRef.value.getBoundingClientRect()
openUpward.value = rect.bottom + MENU_HEIGHT > window.innerHeight
const spaceBelow = window.innerHeight - rect.bottom
const spaceAbove = rect.top
openUpward.value = spaceBelow < MENU_HEIGHT && spaceAbove > spaceBelow
}
isOpen.value = !isOpen.value
}