From 95f466cf6f8ecc506c3c7d35bdfa03461e960be3 Mon Sep 17 00:00:00 2001 From: shilim <1251314045@qq.com> Date: Thu, 18 Jul 2024 23:39:34 +0800 Subject: [PATCH] fix(infinite-scroll): get the correct scrollTop from containerRef, closes #6133 (#6137) Co-authored-by: 07akioni <07akioni2@gmail.com> --- CHANGELOG.en-US.md | 1 + CHANGELOG.zh-CN.md | 1 + src/infinite-scroll/src/InfiniteScroll.tsx | 15 +++++++++------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index c2e499a8d..6bd4d6352 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -23,6 +23,7 @@ - Fix `n-form-item` validation state is not correctly updated [#6068](https://github.com/tusen-ai/naive-ui/issues/6068). - Fix `n-select`'s header make inner input unavailable, closes [#6030](https://github.com/tusen-ai/naive-ui/issues/6030). - Fix `n-tree` may have incorrect node selection status when `show-irrelevant-nodes` is disabled, close [#6115](https://github.com/tusen-ai/naive-ui/issues/6115). +- Fix `n-infinite-scroll` bottoming out judgment error, closes [#6133](https://github.com/tusen-ai/naive-ui/issues/6133). ### Features diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index e0b205db0..931ffb536 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -23,6 +23,7 @@ - 修复 `n-form-item` 状态更新不正常 [#6068](https://github.com/tusen-ai/naive-ui/issues/6068) - 修复 `n-select` 组件的 header 插槽里 input 无法输入,关闭 [#6030](https://github.com/tusen-ai/naive-ui/issues/6030) - 修复 `n-tree` 组件在禁用 `show-irrelevant-nodes` 时,节点的选中状态可能不正确,关闭 [#6115](https://github.com/tusen-ai/naive-ui/issues/6115) +- 修复 `n-infinite-scroll` 组件触底判断错误,关闭 [#6133](https://github.com/tusen-ai/naive-ui/issues/6133) ### Features diff --git a/src/infinite-scroll/src/InfiniteScroll.tsx b/src/infinite-scroll/src/InfiniteScroll.tsx index a4bef7b80..9bdb0efe9 100644 --- a/src/infinite-scroll/src/InfiniteScroll.tsx +++ b/src/infinite-scroll/src/InfiniteScroll.tsx @@ -28,17 +28,20 @@ export default defineComponent({ const handleCheckBottom = async (): Promise => { const { value: scrollbarInst } = scrollbarInstRef if (scrollbarInst) { - const { containerRef, containerScrollTop } = scrollbarInst + const { containerRef } = scrollbarInst const scrollHeight = containerRef?.scrollHeight const clientHeight = containerRef?.clientHeight + const scrollTop = containerRef?.scrollTop + if ( - containerRef - && scrollHeight !== undefined - && clientHeight !== undefined + containerRef && + scrollHeight !== undefined && + clientHeight !== undefined && + scrollTop !== undefined ) { if ( - containerScrollTop + clientHeight - >= scrollHeight - props.distance + scrollTop + clientHeight >= + scrollHeight - props.distance ) { loading = true try {