From 78f6da83997fc299739fba6e0bfc86a486427774 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Mon, 4 Mar 2019 11:24:48 +0100 Subject: [PATCH 1/2] Fixed Search Input --- components/SearchInput.spec.js | 4 ++++ components/SearchInput.vue | 21 +++++++++++++++------ store/search.js | 4 ++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/components/SearchInput.spec.js b/components/SearchInput.spec.js index 5d6c3ed4c..065cc6068 100644 --- a/components/SearchInput.spec.js +++ b/components/SearchInput.spec.js @@ -1,6 +1,10 @@ import { shallowMount, mount } from '@vue/test-utils' import SearchInput from './SearchInput.vue' +import Vue from 'vue' +import Styleguide from '@human-connection/styleguide' +Vue.use(Styleguide) + describe('SearchInput.vue', () => { let wrapper const mocks = { $t: () => {} } diff --git a/components/SearchInput.vue b/components/SearchInput.vue index 773e48d78..b10d5dff9 100644 --- a/components/SearchInput.vue +++ b/components/SearchInput.vue @@ -30,8 +30,9 @@ :icon-right="isActive ? 'close' : null" :filter="item => item" :options="results" + :auto-reset-search="!searchValue" :placeholder="$t('search.placeholder')" - @keypress.enter.prevent.stop.self="onEnter" + @enter="onEnter" @focus.capture.native="onFocus" @blur.capture.native="onBlur" @keyup.delete.native="onDelete" @@ -162,25 +163,32 @@ export default { }, onFocus(e) { clearTimeout(this.searchProcess) + //this.$nextTick(() => { + // this.searchValue = this.lastSearchTerm + //}) this.isOpen = true }, onBlur(e) { + this.searchValue = this.lastSearchTerm + this.$nextTick(() => { + this.searchValue = this.lastSearchTerm + }) this.isOpen = false clearTimeout(this.searchProcess) - this.searchValue = this.lastSearchTerm }, onDelete(e) { clearTimeout(this.searchProcess) const value = e.target ? e.target.value.trim() : '' if (isEmpty(value)) { this.clear() + } else { + this.handleInput(e) } }, /** * TODO: on enter we should go to a dedicated seach page!? */ onEnter(e) { - // console.log('res', this.unprocessedSearchInput) // this.isOpen = false clearTimeout(this.searchProcess) if (!this.pending) { @@ -189,11 +197,12 @@ export default { } }, clear() { + this.$emit('clear') clearTimeout(this.searchProcess) this.isOpen = false - this.searchValue = null - this.lastSearchTerm = null - this.$emit('clear') + this.unprocessedSearchInput = '' + this.lastSearchTerm = '' + this.searchValue = '' } } } diff --git a/store/search.js b/store/search.js index 5402b9b79..32e3b6856 100644 --- a/store/search.js +++ b/store/search.js @@ -70,6 +70,10 @@ export const actions = { commit('SET_QUICK_RESULTS', res.data.findPosts || []) commit('SET_QUICK_PENDING', false) }) + .catch(() => { + commit('SET_QUICK_RESULTS', []) + commit('SET_QUICK_PENDING', false) + }) return getters.quickResults }, async quickClear({ commit }) { From 28fe77db6b46b566a6319876e6a7d1067037e9ea Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Mon, 4 Mar 2019 17:18:55 +0100 Subject: [PATCH 2/2] Use Styleguide 0.5.5 --- package.json | 2 +- yarn.lock | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 96b5f6fda..d8b743868 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "dependencies": { - "@human-connection/styleguide": "~0.5.2", + "@human-connection/styleguide": "~0.5.5", "@nuxtjs/apollo": "4.0.0-rc4", "@nuxtjs/axios": "~5.3.6", "@nuxtjs/dotenv": "~1.3.0", diff --git a/yarn.lock b/yarn.lock index 2de0aa7d5..aa80b2b23 100644 --- a/yarn.lock +++ b/yarn.lock @@ -894,13 +894,10 @@ debug "^3.1.0" lodash.once "^4.1.1" -"@human-connection/styleguide@~0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@human-connection/styleguide/-/styleguide-0.5.2.tgz#a7d05b612562cfbe4377032bdf32df4a8f0e3f45" - integrity sha512-8RSQDv6hRvdToQKtOGv+aNA/lfrNu+eNDy/JBaynJN7bB7veNgQ0XGt9Otq1KmdW2nthWrwsnZLTRaUaGqyAZw== - dependencies: - portal-vue "~1.5.1" - vue "~2.6.7" +"@human-connection/styleguide@~0.5.5": + version "0.5.5" + resolved "https://registry.yarnpkg.com/@human-connection/styleguide/-/styleguide-0.5.5.tgz#17866c78f34ea12c6eb0831e22f4b655a4f222bf" + integrity sha512-QwD8Y2ds1tQbqTpA7sm0J1RUrB7071clcZmKaKHV9BMTrGR4IJhoYWIjOjNWakkM3u9bNm4SY9S/RTKupMuX2A== "@nuxt/babel-preset-app@2.4.5": version "2.4.5" @@ -12376,11 +12373,6 @@ vue@^2.5.22: resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.6.tgz#dde41e483c11c46a7bf523909f4f2f816ab60d25" integrity sha512-Y2DdOZD8sxApS+iUlwv1v8U1qN41kq6Kw45lM6nVZKhygeWA49q7VCCXkjXqeDBXgurrKWkYQ9cJeEJwAq0b9Q== -vue@~2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.7.tgz#254f188e7621d2d19ee28d0c0442c6d21b53ae2d" - integrity sha512-g7ADfQ82QU+j6F/bVDioVQf2ccIMYLuR4E8ev+RsDBlmwRkhGO3HhgF4PF9vpwjdPpxyb1zzLur2nQ2oIMAMEg== - vuex-i18n@~1.11.0: version "1.11.0" resolved "https://registry.yarnpkg.com/vuex-i18n/-/vuex-i18n-1.11.0.tgz#e6cdc95080c445ab2c211cc6b64a907d217639d3"