Skip to content

Commit

Permalink
fix: autocomplete can not reset to undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined committed Sep 10, 2021
1 parent a4d907a commit 741718a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions components/vc-select/generate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,18 @@ export default function generateSelector<
// ============================== Ref ===============================
const selectorDomRef = createRef();

const mergedValue = ref();
const innerSearchValue = ref('');
const setInnerSearchValue = (val: string) => {
innerSearchValue.value = val;
};

const mergedValue = ref(props.value !== undefined ? props.value : props.defaultValue);
watch(
() => props.value,
() => {
mergedValue.value = props.value !== undefined ? props.value : props.defaultValue;
mergedValue.value = props.value;
innerSearchValue.value = '';
},
{ immediate: true },
);
// ============================= Value ==============================

Expand All @@ -429,10 +434,6 @@ export default function generateSelector<
const setActiveValue = (val: string) => {
activeValue.value = val;
};
const innerSearchValue = ref('');
const setInnerSearchValue = (val: string) => {
innerSearchValue.value = val;
};

const mergedSearchValue = computed(() => {
let mergedSearchValue = innerSearchValue.value;
Expand Down

0 comments on commit 741718a

Please sign in to comment.