fix: prevent teleported dropdown from overflowing viewport top

Amp-Thread-ID: https://ampcode.com/threads/T-019d2d64-af34-7489-abd5-cde23ead7105
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Jin Yi
2026-03-27 13:13:38 +09:00
parent 0d21b3aee6
commit 3e587c7758

View File

@@ -178,6 +178,9 @@ function toggleDropdown() {
spaceBelow < MENU_HEIGHT_WITH_GAP && spaceAbove > spaceBelow
if (shouldTeleport) {
if (openUpward.value && rect.top < MENU_HEIGHT_WITH_GAP) {
openUpward.value = false
}
fixedPosition.value = {
top: openUpward.value ? rect.top : rect.bottom,
left: Math.min(rect.right, window.innerWidth - MENU_WIDTH)