From 5da6baf82865bacd83600e858f0f7b44748baa14 Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Fri, 29 Nov 2024 12:00:28 +0100 Subject: [PATCH] fix: prevent jump to table head on continuous scroll load --- web/frontend/src/generic/JobList.svelte | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/frontend/src/generic/JobList.svelte b/web/frontend/src/generic/JobList.svelte index c4aacd2..7915699 100644 --- a/web/frontend/src/generic/JobList.svelte +++ b/web/frontend/src/generic/JobList.svelte @@ -107,7 +107,11 @@ let jobs = [] $: if ($initialized && $jobsStore.data) { - jobs = [...$jobsStore.data.jobs.items] + if (usePaging) { + jobs = [...$jobsStore.data.jobs.items] + } else { // Prevents jump to table head: Extends existing list instead of rendering new list + jobs = jobs.concat([...$jobsStore.data.jobs.items]) + } } $: matchedJobs = $jobsStore.data != null ? $jobsStore.data.jobs.count : -1; @@ -170,7 +174,6 @@ } if (!usePaging) { - let scrollMultiplier = 1 window.addEventListener('scroll', () => { let { scrollTop, @@ -181,8 +184,7 @@ // Add 100 px offset to trigger load earlier if (scrollTop + clientHeight >= scrollHeight - 100 && $jobsStore.data != null && $jobsStore.data.jobs.hasNextPage) { let pendingPaging = { ...paging } - scrollMultiplier += 1 - pendingPaging.itemsPerPage = itemsPerPage * scrollMultiplier + pendingPaging.page += 1 paging = pendingPaging }; });