Skip to content

Commit

Permalink
fix: tag rename to empty string should preserve its original title
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonella Sgarlatta committed Jun 9, 2021
1 parent ead8d5d commit 717d52d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/assets/javascripts/views/tags/tags_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class TagsViewCtrl extends PureViewCtrl<unknown, TagState> {

async clickedAddNewTag() {
if (this.getState().editingTag) {
console.log('editing');
return;
}
const newTag = await this.application.createTemplateItem(
Expand All @@ -289,10 +290,10 @@ class TagsViewCtrl extends PureViewCtrl<unknown, TagState> {

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);
Expand All @@ -314,6 +315,9 @@ class TagsViewCtrl extends PureViewCtrl<unknown, TagState> {
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);
Expand Down

0 comments on commit 717d52d

Please sign in to comment.