Skip to content

Commit 3e05460

Browse files
committed
fix: rowSelection trigger visible warning #4885
close #4885
1 parent 84b9ac5 commit 3e05460

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

components/table/hooks/useSelection.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import devWarning from '../../vc-util/devWarning';
1010
import useMergedState from '../../_util/hooks/useMergedState';
1111
import useState from '../../_util/hooks/useState';
1212
import type { Ref } from 'vue';
13-
import { computed, shallowRef, watchEffect } from 'vue';
13+
import { computed, shallowRef } from 'vue';
1414
import type { CheckboxProps } from '../../checkbox';
1515
import Checkbox from '../../checkbox';
1616
import Dropdown from '../../dropdown';
@@ -167,12 +167,14 @@ export default function useSelection<RecordType>(
167167
// Save last selected key to enable range selection
168168
const [lastSelectedKey, setLastSelectedKey] = useState<Key | null>(null);
169169

170-
// Reset if rowSelection reset
171-
watchEffect(() => {
172-
if (!rowSelectionRef.value) {
173-
setMergedSelectedKeys([]);
174-
}
175-
});
170+
// // Reset if rowSelection reset
171+
// we use computed to reset, donot need setMergedSelectedKeys again like react
172+
// https://github.com/vueComponent/ant-design-vue/issues/4885
173+
// watchEffect(() => {
174+
// if (!rowSelectionRef.value) {
175+
// setMergedSelectedKeys([]);
176+
// }
177+
// });
176178

177179
const setSelectedKeys = (keys: Key[]) => {
178180
let availableKeys: Key[];

0 commit comments

Comments
 (0)