From cc4e02c9387911603d3e37eee4b75a8fa0117be4 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 9 Jun 2020 10:15:13 +0100 Subject: [PATCH] Fixed delete-tag modal showing unexpectedly no issue - there was a race condition when deleting tags... - the delete tag modal's `close` action toggles the `showDeleteTagModal` property to `false` - the `deleteTag` action triggered when clicking the delete button was transitioning to the tags screen - if the transition occurs before the close action is triggered, the modal component is destroyed and it's close action is never triggered leaving the `showDeleteTagModal` property on the controller set to `true` - the next time the tag screen is accessed the delete tag modal is displayed because the `showDeleteTagModal` property is `true` - adds an explicit reset of `showDeleteTagModal` after a tag is successfully destroyed - makes open/close of the delete tag modal explicit actions so there's no ambiguity when toggling --- ghost/admin/app/controllers/tag.js | 9 +++++++-- ghost/admin/app/templates/tag.hbs | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ghost/admin/app/controllers/tag.js b/ghost/admin/app/controllers/tag.js index ea128b9b55..7e9c130fd6 100644 --- a/ghost/admin/app/controllers/tag.js +++ b/ghost/admin/app/controllers/tag.js @@ -28,12 +28,17 @@ export default Controller.extend({ this._saveTagProperty(propKey, value); }, - toggleDeleteTagModal() { - this.toggleProperty('showDeleteTagModal'); + openDeleteTagModal() { + this.set('showDeleteTagModal', true); + }, + + closeDeleteTagModal() { + this.set('showDeleteTagModal', false); }, deleteTag() { return this.tag.destroyRecord().then(() => { + this.set('showDeleteTagModal', false); return this.transitionToRoute('tags'); }, (error) => { return this.notifications.showAPIError(error, {key: 'tag.delete'}); diff --git a/ghost/admin/app/templates/tag.hbs b/ghost/admin/app/templates/tag.hbs index 30fa660165..7def717a73 100644 --- a/ghost/admin/app/templates/tag.hbs +++ b/ghost/admin/app/templates/tag.hbs @@ -18,7 +18,7 @@ {{#unless this.tag.isNew}} - {{/unless}} @@ -37,6 +37,6 @@ @modal="delete-tag" @model={{this.tag}} @confirm={{action "deleteTag"}} - @close={{action "toggleDeleteTagModal"}} + @close={{action "closeDeleteTagModal"}} @modifier="action wide" /> {{/if}} \ No newline at end of file