From d6f3643bf05340540a1728e06ad0263896084a5f Mon Sep 17 00:00:00 2001 From: GitStart <1501599+gitstart@users.noreply.github.com> Date: Tue, 7 Mar 2023 16:57:10 +0300 Subject: [PATCH] fix : Meta tags input in help center clears the input value after clicking outside (#6552) * chore: supports preserving input value after clicking out Co-authored-by: BikashSah999 <51731962+BikashSah999@users.noreply.github.com> * chore: supports tag addition on blur Co-authored-by: BikashSah999 <51731962+BikashSah999@users.noreply.github.com> * feat: use search-change instead of vue-multiselect refs Co-authored-by: BikashSah999 <51731962+BikashSah999@users.noreply.github.com> --------- Co-authored-by: BikashSah999 <51731962+BikashSah999@users.noreply.github.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> --- .../pages/articles/ArticleSettings.vue | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/ArticleSettings.vue b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/ArticleSettings.vue index 773945e15..a8de55770 100644 --- a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/ArticleSettings.vue +++ b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/ArticleSettings.vue @@ -87,6 +87,9 @@ track-by="name" :multiple="true" :taggable="true" + :close-on-select="false" + @search-change="handleSearchChange" + @close="onBlur" @tag="addTagValue" /> @@ -136,6 +139,7 @@ export default { metaDescription: '', metaTags: [], metaOptions: [], + tagInputValue: '', }; }, computed: { @@ -184,13 +188,22 @@ export default { })); }, addTagValue(tagValue) { - const tag = { - name: tagValue, - }; - this.metaTags.push(tag); - this.$refs.tagInput.$el.focus(); + const tags = tagValue + .split(',') + .map(tag => tag.trim()) + .filter(tag => tag && !this.allTags.includes(tag)); + + this.metaTags.push(...this.formattedTags({ tags: [...new Set(tags)] })); this.saveArticle(); }, + handleSearchChange(value) { + this.tagInputValue = value; + }, + onBlur() { + if (this.tagInputValue) { + this.addTagValue(this.tagInputValue); + } + }, onClickSelectCategory({ id }) { this.$emit('save-article', { category_id: id }); },