This commit is contained in:
Timothy Jaeryang Baek committed 2026-02-11 02:20:07 -06:00
1 parent 3e56261c5e
commit 4331029926
1 file changed
+34 -8
@@ -361,6 +361,18 @@
); );
} }
}; };
const ITEM_HEIGHT = 42;
const OVERSCAN = 10;
let listScrollTop = 0;
let listContainer;
$: visibleStart = Math.max(0, Math.floor(listScrollTop / ITEM_HEIGHT) - OVERSCAN);
$: visibleEnd = Math.min(
filteredItems.length,
Math.ceil((listScrollTop + 256) / ITEM_HEIGHT) + OVERSCAN
);
</script> </script>
<DropdownMenu.Root <DropdownMenu.Root
@@ -544,8 +556,25 @@
{/if} {/if}
</div> </div>
<div class="px-2.5 max-h-64 overflow-y-auto group relative"> <div class="px-2.5 group relative">
{#each filteredItems as item, index} {#if filteredItems.length === 0}
<div class="">
<div class="block px-3 py-2 text-sm text-gray-700 dark:text-gray-100">
{$i18n.t('No results found')}
</div>
</div>
{:else}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
class="max-h-64 overflow-y-auto"
bind:this={listContainer}
on:scroll={() => {
listScrollTop = listContainer.scrollTop;
}}
>
<div style="height: {visibleStart * ITEM_HEIGHT}px;" />
{#each filteredItems.slice(visibleStart, visibleEnd) as item, i (item.value)}
{@const index = visibleStart + i}
<ModelItem <ModelItem
{selectedModelIdx} {selectedModelIdx}
{item} {item}
@@ -560,13 +589,10 @@
show = false; show = false;
}} }}
/> />
{:else}
<div class="">
<div class="block px-3 py-2 text-sm text-gray-700 dark:text-gray-100">
{$i18n.t('No results found')}
</div>
</div>
{/each} {/each}
<div style="height: {(filteredItems.length - visibleEnd) * ITEM_HEIGHT}px;" />
</div>
{/if}
{#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user?.role === 'admin'} {#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user?.role === 'admin'}
<Tooltip <Tooltip