From 717d52dd8afab41076ea15488ded6d50d19a659c Mon Sep 17 00:00:00 2001 From: Antonella Sgarlatta Date: Wed, 9 Jun 2021 16:39:19 -0300 Subject: [PATCH] fix: tag rename to empty string should preserve its original title --- app/assets/javascripts/views/tags/tags_view.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/views/tags/tags_view.ts b/app/assets/javascripts/views/tags/tags_view.ts index b44f7b076c7..5a10a69e102 100644 --- a/app/assets/javascripts/views/tags/tags_view.ts +++ b/app/assets/javascripts/views/tags/tags_view.ts @@ -267,6 +267,7 @@ class TagsViewCtrl extends PureViewCtrl { async clickedAddNewTag() { if (this.getState().editingTag) { + console.log('editing'); return; } const newTag = await this.application.createTemplateItem( @@ -289,10 +290,10 @@ class TagsViewCtrl extends PureViewCtrl { async saveTag($event: Event, tag: SNTag) { ($event.target! as HTMLInputElement).blur(); - if (!this.titles[tag.uuid]?.length) { - return this.undoCreateTag(tag); - } if (this.getState().templateTag) { + if (!this.titles[tag.uuid]?.length) { + return this.undoCreateTag(tag); + } return this.saveNewTag(); } else { return this.saveTagRename(tag); @@ -314,6 +315,9 @@ class TagsViewCtrl extends PureViewCtrl { if (newTitle.length === 0) { this.titles[tag.uuid] = this.editingOriginalName; this.editingOriginalName = undefined; + await this.setState({ + editingTag: undefined + }); return; } const existingTag = this.application.findTagByTitle(newTitle);