mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 16:02:14 +00:00
prevent datatable from spamming loadMore on scroll to end (#5973)
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
|
||||
const hasScrollbar = tableContainer.scrollHeight > tableContainer.clientHeight
|
||||
if (!hasScrollbar && hasMore) {
|
||||
dispatch('loadMore')
|
||||
triggerLoadMore()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,11 +92,20 @@
|
||||
|
||||
if (!tableContainer) return
|
||||
const { scrollTop, scrollHeight, clientHeight } = tableContainer
|
||||
if (scrollHeight - (scrollTop + clientHeight) < 50) {
|
||||
dispatch('loadMore')
|
||||
if (scrollHeight - (scrollTop + clientHeight) === 0) {
|
||||
triggerLoadMore()
|
||||
}
|
||||
}
|
||||
|
||||
let lastLoadMoreDispatch: number | undefined = $state(undefined)
|
||||
function triggerLoadMore() {
|
||||
if (lastLoadMoreDispatch && Date.now() - lastLoadMoreDispatch < 1000) {
|
||||
return
|
||||
}
|
||||
dispatch('loadMore')
|
||||
lastLoadMoreDispatch = Date.now()
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (tableContainer && hasMore && !loading) {
|
||||
untrack(() => checkScrollStatus())
|
||||
@@ -170,7 +179,7 @@
|
||||
<Button
|
||||
color="light"
|
||||
size="xs2"
|
||||
on:click={() => dispatch('loadMore')}
|
||||
on:click={() => triggerLoadMore()}
|
||||
endIcon={{ icon: ArrowDownIcon }}
|
||||
>
|
||||
Load {loadMore} more
|
||||
|
||||
Reference in New Issue
Block a user