diff --git a/ghost/admin/app/components/gh-member-label-input.js b/ghost/admin/app/components/gh-member-label-input.js index 198814b156..14c507fa41 100644 --- a/ghost/admin/app/components/gh-member-label-input.js +++ b/ghost/admin/app/components/gh-member-label-input.js @@ -34,6 +34,16 @@ export default Component.extend({ this.set('_availableLabels', this.store.peekAll('label')); }, + willDestroyElement() { + // NOTE: cleans up labels store in case they were not persisted, this avoids unsaved labels + // from appearing on different input instances when unsaved + this.get('_availableLabels').forEach((label) => { + if (label.get('isNew')) { + this.store.deleteRecord(label); + } + }); + }, + actions: { matchLabels(labelName, term) { return labelName.toLowerCase() === term.trim().toLowerCase(); diff --git a/ghost/admin/app/controllers/members.js b/ghost/admin/app/controllers/members.js index 0c08b75877..b36f628c9d 100644 --- a/ghost/admin/app/controllers/members.js +++ b/ghost/admin/app/controllers/members.js @@ -165,11 +165,7 @@ export default class MembersController extends Controller { @task *fetchLabelsTask() { - if (!this._hasLoadedLabels) { - yield this.store.query('label', {limit: 'all'}).then(() => { - this._hasLoadedLabels = true; - }); - } + yield this.store.query('label', {limit: 'all'}); } @task({restartable: true})