Skip to content

Commit

Permalink
fix(vue): auto-suggestion dropdown with controlled behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
bietkul committed Aug 28, 2020
1 parent 6bb9d9e commit ee674c5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/vue/src/components/search/DataSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const DataSearch = {
},
value(newVal, oldVal) {
if (!isEqual(newVal, oldVal)) {
this.setValue(newVal, true, this.$props);
this.setValue(newVal, true, this.$props, undefined, false);
}
},
defaultQuery(newVal, oldVal) {
Expand Down Expand Up @@ -316,13 +316,15 @@ const DataSearch = {
this.onValueSelectedHandler(currentValue, causes.SEARCH_ICON_CLICK);
}
},
setValue(value, isDefaultValue = false, props = this.$props, cause) {
setValue(value, isDefaultValue = false, props = this.$props, cause, toggleIsOpen = true) {
const performUpdate = () => {
this.currentValue = value;
this.normalizedSuggestions = [];
if (isDefaultValue) {
if (this.$props.autosuggest) {
this.isOpen = false;
if (toggleIsOpen) {
this.isOpen = false;
}
this.updateDefaultQueryHandler(value, this.$props);
} // in case of strict selection only SUGGESTION_SELECT should be able
// to set the query otherwise the value should reset
Expand Down Expand Up @@ -480,7 +482,6 @@ const DataSearch = {
}

const { value } = this.$props;

if (value === undefined) {
this.setValue(inputValue);
} else {
Expand Down

0 comments on commit ee674c5

Please sign in to comment.