From e15c41f549087370875a1768526b99dd9678ab1e Mon Sep 17 00:00:00 2001 From: tbl0605 Date: Tue, 18 May 2021 14:55:56 +0200 Subject: [PATCH 1/2] Workaround graphical glitch when using async data retrieval and debouncing --- dist/cjs.js | 12 ++++++------ dist/es6.js | 12 ++++++------ dist/es7.js | 3 ++- dist/iife.js | 2 +- dist/umd.js | 2 +- lib/vue-simple-suggest.vue | 3 ++- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/dist/cjs.js b/dist/cjs.js index 1173120..c113db6 100644 --- a/dist/cjs.js +++ b/dist/cjs.js @@ -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(); @@ -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")) { @@ -653,6 +652,7 @@ function _await(value, then, direct) { _this12.$emit('request-start', value); } + _this12.isPlainSuggestion = false; var result = []; return _finally(function () { return _catch(function () { @@ -671,7 +671,7 @@ function _await(value, then, direct) { result = [result]; } - _this12.isPlainSuggestion = _typeof(result[0]) !== 'object' || Array.isArray(result[0]); + _this12.isPlainSuggestion = _typeof(result[0]) !== 'object' && typeof result[0] !== 'undefined' || Array.isArray(result[0]); if (_this12.filterByQuery) { result = result.filter(function (el) { diff --git a/dist/es6.js b/dist/es6.js index fde3193..b6b268c 100644 --- a/dist/es6.js +++ b/dist/es6.js @@ -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(); @@ -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")) { @@ -617,6 +616,7 @@ function _await(value, then, direct) { _this4.$emit('request-start', value); } + _this4.isPlainSuggestion = false; let result = []; return _finally(function () { return _catch(function () { @@ -635,7 +635,7 @@ function _await(value, then, direct) { result = [result]; } - _this4.isPlainSuggestion = typeof result[0] !== 'object' || Array.isArray(result[0]); + _this4.isPlainSuggestion = typeof result[0] !== 'object' && typeof result[0] !== 'undefined' || Array.isArray(result[0]); if (_this4.filterByQuery) { result = result.filter(el => _this4.filter(el, value)); diff --git a/dist/es7.js b/dist/es7.js index 26c9b63..eab6d9d 100644 --- a/dist/es7.js +++ b/dist/es7.js @@ -553,6 +553,7 @@ var VueSimpleSuggest = { this.$emit('request-start', value); } + this.isPlainSuggestion = false; let result = []; try { if (this.listIsRequest) { @@ -566,7 +567,7 @@ var VueSimpleSuggest = { result = [result]; } - this.isPlainSuggestion = typeof result[0] !== 'object' || Array.isArray(result[0]); + this.isPlainSuggestion = typeof result[0] !== 'object' && typeof result[0] !== 'undefined' || Array.isArray(result[0]); if (this.filterByQuery) { result = result.filter(el => this.filter(el, value)); diff --git a/dist/iife.js b/dist/iife.js index 769bb0a..3e8ab3b 100644 --- a/dist/iife.js +++ b/dist/iife.js @@ -1 +1 @@ -var VueSimpleSuggest=function(){"use strict";var t={selectionUp:[38],selectionDown:[40],select:[13],hideList:[27],showList:[40],autocomplete:[32,13]},e={input:String,select:Object};function r(t,e){return i(t,e.keyCode)}function i(t,e){if(t.length<=0)return!1;function s(t){return t.some(function(t){return t===e})}return Array.isArray(t[0])?t.some(function(t){return s(t)}):s(t)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=Object.assign||function(t){for(var e=1;e=this.minLength&&(0=this.minLength&&(0=this.minLength&&(0=this.minLength&&(0 this.filter(el, value)) From 731f1468dae2776a128f0ff183ad8d03857e48d9 Mon Sep 17 00:00:00 2001 From: tbl0605 Date: Thu, 20 May 2021 12:33:40 +0200 Subject: [PATCH 2/2] rework initial patch --- dist/cjs.js | 5 +++-- dist/es6.js | 5 +++-- dist/es7.js | 5 +++-- dist/iife.js | 2 +- dist/umd.js | 2 +- lib/vue-simple-suggest.vue | 5 +++-- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dist/cjs.js b/dist/cjs.js index c113db6..79dae64 100644 --- a/dist/cjs.js +++ b/dist/cjs.js @@ -652,7 +652,7 @@ var VueSimpleSuggest = { _this12.$emit('request-start', value); } - _this12.isPlainSuggestion = false; + var nextIsPlainSuggestion = false; var result = []; return _finally(function () { return _catch(function () { @@ -671,7 +671,7 @@ var VueSimpleSuggest = { result = [result]; } - _this12.isPlainSuggestion = _typeof(result[0]) !== 'object' && typeof result[0] !== 'undefined' || 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) { @@ -695,6 +695,7 @@ var VueSimpleSuggest = { result.splice(_this12.maxSuggestions); } + _this12.isPlainSuggestion = nextIsPlainSuggestion; return result; }); } catch (e) { diff --git a/dist/es6.js b/dist/es6.js index b6b268c..70e3033 100644 --- a/dist/es6.js +++ b/dist/es6.js @@ -616,7 +616,7 @@ var VueSimpleSuggest = { _this4.$emit('request-start', value); } - _this4.isPlainSuggestion = false; + let nextIsPlainSuggestion = false; let result = []; return _finally(function () { return _catch(function () { @@ -635,7 +635,7 @@ var VueSimpleSuggest = { result = [result]; } - _this4.isPlainSuggestion = typeof result[0] !== 'object' && typeof result[0] !== 'undefined' || 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)); @@ -657,6 +657,7 @@ var VueSimpleSuggest = { result.splice(_this4.maxSuggestions); } + _this4.isPlainSuggestion = nextIsPlainSuggestion; return result; }); }), diff --git a/dist/es7.js b/dist/es7.js index eab6d9d..62979c3 100644 --- a/dist/es7.js +++ b/dist/es7.js @@ -553,7 +553,7 @@ var VueSimpleSuggest = { this.$emit('request-start', value); } - this.isPlainSuggestion = false; + let nextIsPlainSuggestion = false; let result = []; try { if (this.listIsRequest) { @@ -567,7 +567,7 @@ var VueSimpleSuggest = { result = [result]; } - this.isPlainSuggestion = typeof result[0] !== 'object' && typeof result[0] !== 'undefined' || 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)); @@ -587,6 +587,7 @@ var VueSimpleSuggest = { result.splice(this.maxSuggestions); } + this.isPlainSuggestion = nextIsPlainSuggestion; return result; } }, diff --git a/dist/iife.js b/dist/iife.js index 3e8ab3b..20745ad 100644 --- a/dist/iife.js +++ b/dist/iife.js @@ -1 +1 @@ -var VueSimpleSuggest=function(){"use strict";var t={selectionUp:[38],selectionDown:[40],select:[13],hideList:[27],showList:[40],autocomplete:[32,13]},e={input:String,select:Object};function r(t,e){return i(t,e.keyCode)}function i(t,e){if(t.length<=0)return!1;function s(t){return t.some(function(t){return t===e})}return Array.isArray(t[0])?t.some(function(t){return s(t)}):s(t)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=Object.assign||function(t){for(var e=1;e=this.minLength&&(0=this.minLength&&(0=this.minLength&&(0=this.minLength&&(0 this.filter(el, value)) @@ -617,6 +617,7 @@ export default { result.splice(this.maxSuggestions) } + this.isPlainSuggestion = nextIsPlainSuggestion return result } },