From aea25100e57fe0e15bbfa6edaedc1c1bb4d1ff07 Mon Sep 17 00:00:00 2001
From: tanjinzhou <415800467@qq.com>
Date: Tue, 22 Dec 2020 13:22:14 +0800
Subject: [PATCH] fix: select scroll height not correct #3419

---
 antdv-demo                                      |  2 +-
 components/vc-virtual-list/List.tsx             |  3 +--
 components/vc-virtual-list/hooks/useHeights.tsx | 10 ++++------
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/antdv-demo b/antdv-demo
index db458a227..8269bbdf1 160000
--- a/antdv-demo
+++ b/antdv-demo
@@ -1 +1 @@
-Subproject commit db458a2276cd9156a7824f4e876de5702efd9ff7
+Subproject commit 8269bbdf109ab684626cd8ef0c4fc5f0c2222210
diff --git a/components/vc-virtual-list/List.tsx b/components/vc-virtual-list/List.tsx
index 9e0a6e03a..fd0317ebe 100644
--- a/components/vc-virtual-list/List.tsx
+++ b/components/vc-virtual-list/List.tsx
@@ -133,7 +133,7 @@ const List = defineComponent({
     }
 
     // ================================ Height ================================
-    const [setInstance, collectHeight, heights, heightUpdatedMark] = useHeights(getKey, null, null);
+    const [setInstance, collectHeight, heights] = useHeights(getKey, null, null);
     // ========================== Visible Calculation =========================
     const calRes = computed(() => {
       if (!useVirtual.value) {
@@ -194,7 +194,6 @@ const List = defineComponent({
       // Give cache to improve scroll experience
       endIndex = Math.min(endIndex + 1, state.mergedData.length);
       return {
-        heightUpdatedMark,
         scrollHeight: itemTop,
         start: startIndex,
         end: endIndex,
diff --git a/components/vc-virtual-list/hooks/useHeights.tsx b/components/vc-virtual-list/hooks/useHeights.tsx
index 52e4c42d6..e71916263 100644
--- a/components/vc-virtual-list/hooks/useHeights.tsx
+++ b/components/vc-virtual-list/hooks/useHeights.tsx
@@ -1,4 +1,4 @@
-import { Ref, ref, VNodeProps } from 'vue';
+import { reactive, VNodeProps } from 'vue';
 import { GetKey } from '../interface';
 
 type CacheMap = Record<string, number>;
@@ -7,10 +7,9 @@ export default function useHeights<T>(
   getKey: GetKey<T>,
   onItemAdd?: ((item: T) => void) | null,
   onItemRemove?: ((item: T) => void) | null,
-): [(item: T, instance: HTMLElement) => void, () => void, CacheMap, Ref<number>] {
+): [(item: T, instance: HTMLElement) => void, () => void, CacheMap] {
   const instance = new Map<VNodeProps['key'], HTMLElement>();
-  const heights = {};
-  const updatedMark = ref(0);
+  const heights = reactive({});
   let heightUpdateId = 0;
   function collectHeight() {
     heightUpdateId += 1;
@@ -28,7 +27,6 @@ export default function useHeights<T>(
           }
         }
       });
-      updatedMark.value++;
     });
   }
 
@@ -53,5 +51,5 @@ export default function useHeights<T>(
     }
   }
 
-  return [setInstance, collectHeight, heights, updatedMark];
+  return [setInstance, collectHeight, heights];
 }