From 6fa50a6558bdfc3bdaf77917870e554b3905a8dc Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Sun, 30 Aug 2026 12:06:27 -0400 Subject: [PATCH] fix: keep select dropdowns inside the viewport (#29226) --- src/lib/components/common/Select.svelte | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib/components/common/Select.svelte b/src/lib/components/common/Select.svelte index efa8456d05..93a151d227 100644 --- a/src/lib/components/common/Select.svelte +++ b/src/lib/components/common/Select.svelte @@ -74,11 +74,21 @@ contentEl.style.bottom = 'auto'; } + const contentWidth = contentEl.offsetWidth || 0; + if (align === 'end') { - contentEl.style.right = `${window.innerWidth - rect.right}px`; + let right = window.innerWidth - rect.right; + if (right + contentWidth > window.innerWidth) { + right = window.innerWidth - contentWidth - 16; + } + contentEl.style.right = `${Math.max(16, right)}px`; contentEl.style.left = 'auto'; } else { - contentEl.style.left = `${rect.left}px`; + let left = rect.left; + if (left + contentWidth + 16 > window.innerWidth) { + left = window.innerWidth - contentWidth - 16; + } + contentEl.style.left = `${Math.max(16, left)}px`; contentEl.style.right = 'auto'; } }