Skip to content

Commit

Permalink
fix: rowSelection trigger visible warning #4885
Browse files Browse the repository at this point in the history
close #4885
  • Loading branch information
tangjinzhou committed Nov 20, 2021
1 parent 84b9ac5 commit 3e05460
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions components/table/hooks/useSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -167,12 +167,14 @@ export default function useSelection<RecordType>(
// Save last selected key to enable range selection
const [lastSelectedKey, setLastSelectedKey] = useState<Key | null>(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[];
Expand Down

0 comments on commit 3e05460

Please sign in to comment.