mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-11 03:38:02 +00:00
fix: open select lists upward when there is no room below (#32153)
Select always placed its list on the requested side, so a list opened near the bottom of the window (such as the model selector's filter list) ran off the screen. It now flips to the other side when the requested side is too short and the other side has more room, the same check the shared Dropdown already uses.
This commit is contained in:
parent
d3acc2706d
commit
c65ce18a9a
1 changed files with 13 additions and 1 deletions
|
|
@ -66,7 +66,19 @@
|
|||
contentEl.style.position = 'fixed';
|
||||
contentEl.style.zIndex = '9999';
|
||||
contentEl.style.minWidth = `${rect.width}px`;
|
||||
if (side === 'top') {
|
||||
|
||||
const contentHeight = contentEl.offsetHeight || 0;
|
||||
const spaceBelow = window.innerHeight - rect.bottom - 4;
|
||||
const spaceAbove = rect.top - 4;
|
||||
|
||||
let openAbove = side === 'top';
|
||||
if (side === 'bottom' && spaceBelow < contentHeight && spaceAbove > spaceBelow) {
|
||||
openAbove = true;
|
||||
} else if (side === 'top' && spaceAbove < contentHeight && spaceBelow > spaceAbove) {
|
||||
openAbove = false;
|
||||
}
|
||||
|
||||
if (openAbove) {
|
||||
contentEl.style.bottom = `${window.innerHeight - rect.top + 4}px`;
|
||||
contentEl.style.top = 'auto';
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue