Merge pull request #921 from mathuo/883-tab-overflow-dropdown-doesnt-collide-with-edge-of-screen

883 tab overflow dropdown doesnt collide with edge of screen
This commit is contained in:
mathuo 2025-04-30 20:43:39 +01:00 committed by GitHub
commit 093a034738
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -459,10 +459,7 @@ export function shiftAbsoluteElementIntoView(
) {
const buffer = options.buffer;
const rect = element.getBoundingClientRect();
const rootRect = element.getBoundingClientRect();
const viewportWidth = root.clientWidth;
const viewportHeight = root.clientHeight;
const rootRect = root.getBoundingClientRect();
let translateX = 0;
let translateY = 0;
@ -475,15 +472,15 @@ export function shiftAbsoluteElementIntoView(
// Check horizontal overflow
if (left < buffer) {
translateX = buffer - left;
} else if (right > viewportWidth - buffer) {
translateX = viewportWidth - right - buffer;
} else if (right > buffer) {
translateX = -buffer - right;
}
// Check vertical overflow
if (top < buffer) {
translateY = buffer - top;
} else if (bottom > viewportHeight - buffer) {
translateY = viewportHeight - bottom - buffer;
} else if (bottom > buffer) {
translateY = -bottom - buffer;
}
// Apply the translation if needed