Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix graphical glitch when using async data retrieval and debouncing #442

Merged
merged 2 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions dist/cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ function _await(value, then, direct) {
var result = body();
} catch (e) {
return recover(e);
}
if (result && result.then) {
}if (result && result.then) {
return result.then(void 0, recover);
}
return result;
}return result;
}function _finally(body, finalizer) {
try {
var result = body();
Expand All @@ -83,7 +81,8 @@ function _await(value, then, direct) {
}if (result && result.then) {
return result.then(finalizer, finalizer);
}return finalizer();
}var VueSimpleSuggest = {
}
var VueSimpleSuggest = {
render: function render() {
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('div', { staticClass: "vue-simple-suggest", class: [_vm.styles.vueSimpleSuggest, { designed: !_vm.destyled, focus: _vm.isInFocus }], on: { "keydown": function keydown($event) {
if (!$event.type.indexOf('key') && _vm._k($event.keyCode, "tab", 9, $event.key, "Tab")) {
Expand Down Expand Up @@ -653,6 +652,7 @@ function _await(value, then, direct) {
_this12.$emit('request-start', value);
}

var nextIsPlainSuggestion = false;
var result = [];
return _finally(function () {
return _catch(function () {
Expand All @@ -671,7 +671,7 @@ function _await(value, then, direct) {
result = [result];
}

_this12.isPlainSuggestion = _typeof(result[0]) !== 'object' || Array.isArray(result[0]);
nextIsPlainSuggestion = _typeof(result[0]) !== 'object' && typeof result[0] !== 'undefined' || Array.isArray(result[0]);

if (_this12.filterByQuery) {
result = result.filter(function (el) {
Expand All @@ -695,6 +695,7 @@ function _await(value, then, direct) {
result.splice(_this12.maxSuggestions);
}

_this12.isPlainSuggestion = nextIsPlainSuggestion;
return result;
});
} catch (e) {
Expand Down
13 changes: 7 additions & 6 deletions dist/es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ function _await(value, then, direct) {
var result = body();
} catch (e) {
return recover(e);
}
if (result && result.then) {
}if (result && result.then) {
return result.then(void 0, recover);
}
return result;
}return result;
}function _finally(body, finalizer) {
try {
var result = body();
Expand All @@ -77,7 +75,8 @@ function _await(value, then, direct) {
}if (result && result.then) {
return result.then(finalizer, finalizer);
}return finalizer();
}var VueSimpleSuggest = {
}
var VueSimpleSuggest = {
render: function () {
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('div', { staticClass: "vue-simple-suggest", class: [_vm.styles.vueSimpleSuggest, { designed: !_vm.destyled, focus: _vm.isInFocus }], on: { "keydown": function ($event) {
if (!$event.type.indexOf('key') && _vm._k($event.keyCode, "tab", 9, $event.key, "Tab")) {
Expand Down Expand Up @@ -617,6 +616,7 @@ function _await(value, then, direct) {
_this4.$emit('request-start', value);
}

let nextIsPlainSuggestion = false;
let result = [];
return _finally(function () {
return _catch(function () {
Expand All @@ -635,7 +635,7 @@ function _await(value, then, direct) {
result = [result];
}

_this4.isPlainSuggestion = typeof result[0] !== 'object' || Array.isArray(result[0]);
nextIsPlainSuggestion = typeof result[0] !== 'object' && typeof result[0] !== 'undefined' || Array.isArray(result[0]);

if (_this4.filterByQuery) {
result = result.filter(el => _this4.filter(el, value));
Expand All @@ -657,6 +657,7 @@ function _await(value, then, direct) {
result.splice(_this4.maxSuggestions);
}

_this4.isPlainSuggestion = nextIsPlainSuggestion;
return result;
});
}),
Expand Down
4 changes: 3 additions & 1 deletion dist/es7.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ var VueSimpleSuggest = {
this.$emit('request-start', value);
}

let nextIsPlainSuggestion = false;
let result = [];
try {
if (this.listIsRequest) {
Expand All @@ -566,7 +567,7 @@ var VueSimpleSuggest = {
result = [result];
}

this.isPlainSuggestion = typeof result[0] !== 'object' || Array.isArray(result[0]);
nextIsPlainSuggestion = typeof result[0] !== 'object' && typeof result[0] !== 'undefined' || Array.isArray(result[0]);

if (this.filterByQuery) {
result = result.filter(el => this.filter(el, value));
Expand All @@ -586,6 +587,7 @@ var VueSimpleSuggest = {
result.splice(this.maxSuggestions);
}

this.isPlainSuggestion = nextIsPlainSuggestion;
return result;
}
},
Expand Down
2 changes: 1 addition & 1 deletion dist/iife.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/umd.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion lib/vue-simple-suggest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ export default {
this.$emit('request-start', value)
}

let nextIsPlainSuggestion = false
let result = []
try {
if (this.listIsRequest) {
Expand All @@ -592,7 +593,7 @@ export default {
// IFF the result is not an array (just in case!) - make it an array
if (!Array.isArray(result)) { result = [result] }

this.isPlainSuggestion = (typeof result[0] !== 'object') || Array.isArray(result[0])
nextIsPlainSuggestion = (typeof result[0] !== 'object' && typeof result[0] !== 'undefined') || Array.isArray(result[0])

if (this.filterByQuery) {
result = result.filter((el) => this.filter(el, value))
Expand All @@ -616,6 +617,7 @@ export default {
result.splice(this.maxSuggestions)
}

this.isPlainSuggestion = nextIsPlainSuggestion
return result
}
},
Expand Down