mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-15 09:31:21 +00:00
fix: reposition the model selector dropdown when its content changes size after opening
This commit is contained in:
parent
8383bc708c
commit
8b344aed15
1 changed files with 17 additions and 0 deletions
|
|
@ -209,6 +209,7 @@
|
|||
updatePosition();
|
||||
await tick();
|
||||
updatePosition();
|
||||
scheduleSettledPositionUpdates();
|
||||
for (const delay of [0, 50, 150]) {
|
||||
window.setTimeout(focusSearchInput, delay);
|
||||
}
|
||||
|
|
@ -960,6 +961,21 @@
|
|||
};
|
||||
};
|
||||
|
||||
const trackContentSize = (node: HTMLElement) => {
|
||||
if (!('ResizeObserver' in window)) {
|
||||
return { destroy() {} };
|
||||
}
|
||||
|
||||
const observer = new ResizeObserver(schedulePositionUpdate);
|
||||
observer.observe(node);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
observer.disconnect();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
$: visibleStart = Math.max(0, Math.floor(listScrollTop / ITEM_HEIGHT) - OVERSCAN);
|
||||
$: visibleEnd = Math.min(
|
||||
filteredItems.length,
|
||||
|
|
@ -1027,6 +1043,7 @@
|
|||
>
|
||||
<div
|
||||
bind:this={panelElement}
|
||||
use:trackContentSize
|
||||
class="z-40 {className ??
|
||||
'w-[20rem]'} max-w-[calc(100vw-1rem)] justify-start rounded-xl border border-gray-100 bg-white p-0.5 shadow-lg outline-hidden dark:border-gray-800 dark:bg-gray-850 dark:text-white flex flex-col overflow-hidden"
|
||||
style={dropdownPosition.maxHeight ? `max-height: ${dropdownPosition.maxHeight}px;` : ''}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue