mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-03 18:17:56 -05:00
fix(a11y): menus fit the space they open into, so a short window no longer pushes items off screen (#35465)
This commit is contained in:
1 file changed
+12
-5
@@ -48,6 +48,7 @@
|
||||
let settleTimers: number[] = [];
|
||||
let resolvedMaxHeight = maxHeight ?? DEFAULT_MAX_HEIGHT;
|
||||
let lastContentHeight = 0;
|
||||
let heightConstrained = false;
|
||||
|
||||
/** Svelte action: moves the node to document.body and keeps it positioned as it resizes */
|
||||
function portal(node: HTMLElement) {
|
||||
@@ -158,6 +159,12 @@
|
||||
contentEl.style.bottom = 'auto';
|
||||
}
|
||||
|
||||
const availableHeight = Math.max(0, openAbove ? spaceAbove : spaceBelow);
|
||||
heightConstrained = contentHeight > availableHeight;
|
||||
if (heightConstrained) {
|
||||
resolvedMaxHeight = `min(${effectiveMaxHeight}, ${availableHeight}px)`;
|
||||
}
|
||||
|
||||
if (align === 'end') {
|
||||
let right = window.innerWidth - rect.right;
|
||||
// Shift if overflowing left edge
|
||||
@@ -226,10 +233,10 @@
|
||||
}
|
||||
contentEl.style.left = `${Math.max(viewport.left + pad, Math.min(preferredLeft, maxLeft))}px`;
|
||||
contentEl.style.right = 'auto';
|
||||
resolvedMaxHeight =
|
||||
contentHeight > availableHeight
|
||||
? `min(${effectiveMaxHeight}, ${availableHeight}px)`
|
||||
: effectiveMaxHeight;
|
||||
heightConstrained = contentHeight > availableHeight;
|
||||
resolvedMaxHeight = heightConstrained
|
||||
? `min(${effectiveMaxHeight}, ${availableHeight}px)`
|
||||
: effectiveMaxHeight;
|
||||
contentEl.style.maxHeight = resolvedMaxHeight;
|
||||
}
|
||||
|
||||
@@ -431,7 +438,7 @@
|
||||
<div
|
||||
use:portal
|
||||
bind:this={contentEl}
|
||||
class="no-drag-region {contentClass}"
|
||||
class="no-drag-region {heightConstrained ? 'overflow-y-auto' : ''} {contentClass}"
|
||||
role="menu"
|
||||
tabindex="-1"
|
||||
style:max-height={resolvedMaxHeight}
|
||||
|
||||
Reference in new issue
Block a user