From 3e05460d09fa292efc83309212eb3a76a2cef4f7 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sat, 20 Nov 2021 16:06:56 +0800 Subject: [PATCH] fix: rowSelection trigger visible warning #4885 close #4885 --- components/table/hooks/useSelection.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/components/table/hooks/useSelection.tsx b/components/table/hooks/useSelection.tsx index 433e5ca37..bda0e3630 100644 --- a/components/table/hooks/useSelection.tsx +++ b/components/table/hooks/useSelection.tsx @@ -10,7 +10,7 @@ import devWarning from '../../vc-util/devWarning'; import useMergedState from '../../_util/hooks/useMergedState'; import useState from '../../_util/hooks/useState'; import type { Ref } from 'vue'; -import { computed, shallowRef, watchEffect } from 'vue'; +import { computed, shallowRef } from 'vue'; import type { CheckboxProps } from '../../checkbox'; import Checkbox from '../../checkbox'; import Dropdown from '../../dropdown'; @@ -167,12 +167,14 @@ export default function useSelection( // Save last selected key to enable range selection const [lastSelectedKey, setLastSelectedKey] = useState(null); - // Reset if rowSelection reset - watchEffect(() => { - if (!rowSelectionRef.value) { - setMergedSelectedKeys([]); - } - }); + // // Reset if rowSelection reset + // we use computed to reset, donot need setMergedSelectedKeys again like react + // https://github.com/vueComponent/ant-design-vue/issues/4885 + // watchEffect(() => { + // if (!rowSelectionRef.value) { + // setMergedSelectedKeys([]); + // } + // }); const setSelectedKeys = (keys: Key[]) => { let availableKeys: Key[];