diff --git a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte index b4efb098..f5a223f3 100644 --- a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte +++ b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte @@ -2,8 +2,9 @@ import type { Post } from 'lemmy-js-client' import type { CommentNodeI } from './comments.svelte' import Comments from './Comments.svelte' - import { onMount } from 'svelte' + import { onMount, tick } from 'svelte' import VirtualList from '$lib/components/render/VirtualList.svelte' + import { page } from '$app/state' interface Props { nodes: CommentNodeI[] @@ -14,6 +15,7 @@ let { nodes, post, scrollTo }: Props = $props() let offsetEl = $state() + let list = $state() let initialOffset = $state(0) @@ -55,6 +57,7 @@ overscan={500} items={nodes} {initialOffset} + bind:this={list} > {#snippet item(item, index)}
diff --git a/src/lib/components/render/VirtualList.svelte b/src/lib/components/render/VirtualList.svelte index ed84c6af..adfede9c 100644 --- a/src/lib/components/render/VirtualList.svelte +++ b/src/lib/components/render/VirtualList.svelte @@ -3,7 +3,7 @@ import { debounce } from 'mono-svelte/util/time' import { onDestroy, tick, untrack, type Snippet } from 'svelte' import type { HTMLAttributes } from 'svelte/elements' - import { innerHeight } from 'svelte/reactivity/window' + import { innerHeight, scrollY } from 'svelte/reactivity/window' interface Props extends HTMLAttributes { items: T[] diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index 598be0b0..7b6efc2b 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -206,25 +206,27 @@
- {#each data.results.value as result} - {#if isPostView(result)} - - {:else if isCommentView(result)} - - {:else if isCommunityView(result)} -
- -
- {:else if isUser(result)} -
- -
- {/if} - {/each} + {#key data.results.value} + {#each data.results.value as result} + {#if isPostView(result)} + + {:else if isCommentView(result)} + + {:else if isCommunityView(result)} +
+ +
+ {:else if isUser(result)} +
+ +
+ {/if} + {/each} + {/key}
{#if data.results.value.length > 0} diff --git a/src/routes/search/+page.ts b/src/routes/search/+page.ts index ce00e89c..a6571afe 100644 --- a/src/routes/search/+page.ts +++ b/src/routes/search/+page.ts @@ -1,6 +1,6 @@ import { profile } from '$lib/auth.svelte' import { client, getClient } from '$lib/lemmy.svelte.js' -import { getItemPublished } from '$lib/lemmy/item.js' +import { getItemPublished, isPostView } from '$lib/lemmy/item.js' import { ReactiveState } from '$lib/promise.svelte.js' import type { CommentView,