fix(infinite-scroll): get the correct scrollTop from containerRef, closes #6133 (#6137)

Co-authored-by: 07akioni <07akioni2@gmail.com>
This commit is contained in:
shilim 2024-07-18 23:39:34 +08:00 committed by GitHub
parent 5cba49c9ad
commit 95f466cf6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -28,17 +28,20 @@ export default defineComponent({
const handleCheckBottom = async (): Promise<void> => {
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 {