From efff3625a9ca30e9dba75b18cb6bcdf1a87374f7 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 25 Apr 2023 04:07:26 +0200 Subject: [PATCH] properly diferentiate between clearbale search and text hints --- .../generic/SearchableInput/SearchableInput.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/webapp/components/generic/SearchableInput/SearchableInput.vue b/webapp/components/generic/SearchableInput/SearchableInput.vue index c27b16b66..987fd596b 100644 --- a/webapp/components/generic/SearchableInput/SearchableInput.vue +++ b/webapp/components/generic/SearchableInput/SearchableInput.vue @@ -84,13 +84,16 @@ export default { }, computed: { emptyText() { - return this.isActive && !this.loading ? this.$t('search.failed') : this.$t('search.hint') + return !this.loading && this.isSearchable() ? this.$t('search.failed') : this.$t('search.hint') }, isActive() { return !isEmpty(this.value) }, }, methods: { + isSearchable(){ + return !isEmpty(this.value) && typeof this.value === 'string' && this.value.replace(/\s+/g, '').length >= 3 + }, isFirstOfType(option) { return ( this.options.findIndex((o) => o === option) === @@ -103,8 +106,8 @@ export default { onInput(event) { clearTimeout(this.searchProcess) this.value = event.target ? event.target.value.replace(/\s+/g, ' ').trim() : '' - if (isEmpty(this.value) || this.value.replace(/\s+/g, '').length < 3) { - this.clear() + if (!this.isSearchable()) { + this.$emit('clearSearch') return } this.searchProcess = setTimeout(() => { @@ -120,7 +123,6 @@ export default { }, clear() { this.value = '' - this.valueBackup = '' this.$emit('clearSearch') clearTimeout(this.searchProcess) },