diff --git a/ghost/admin/app/components/posts-list/modals/add-tag.hbs b/ghost/admin/app/components/posts-list/modals/add-tag.hbs
index 45fb235d21..8d82cc343e 100644
--- a/ghost/admin/app/components/posts-list/modals/add-tag.hbs
+++ b/ghost/admin/app/components/posts-list/modals/add-tag.hbs
@@ -6,19 +6,22 @@
@@ -29,8 +32,7 @@
@buttonText="Add"
@runningText="Adding"
@showSuccess={{false}}
- @task={{@data.confirm}}
- @taskArgs={{this.selectedTags}}
+ @task={{this.confirm}}
@class="gh-btn gh-btn-green gh-btn-icon"
data-test-button="confirm"
/>
diff --git a/ghost/admin/app/components/posts-list/modals/add-tag.js b/ghost/admin/app/components/posts-list/modals/add-tag.js
index 50f888a0eb..6f125acb47 100644
--- a/ghost/admin/app/components/posts-list/modals/add-tag.js
+++ b/ghost/admin/app/components/posts-list/modals/add-tag.js
@@ -1,7 +1,10 @@
import Component from '@glimmer/component';
+import DS from 'ember-data'; // eslint-disable-line
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
+import {task} from 'ember-concurrency';
import {tracked} from '@glimmer/tracking';
+const {Errors} = DS;
export default class AddTag extends Component {
@service store;
@@ -11,10 +14,17 @@ export default class AddTag extends Component {
@tracked
selectedTags = [];
+ @tracked
+ errors = Errors.create();
+
get availableTags() {
return this.#availableTags || [];
}
+ get hasValidated() {
+ return ['tags'];
+ }
+
constructor() {
super(...arguments);
// perform a background query to fetch all users and set `availableTags`
@@ -41,6 +51,16 @@ export default class AddTag extends Component {
this.selectedTags = newTags;
}
+ @task
+ *confirm() {
+ if (this.selectedTags.length === 0) {
+ this.errors.add('tags', 'Select at least one tag');
+ return;
+ }
+ this.errors.clear();
+ yield this.args.data.confirm.perform(this.selectedTags);
+ }
+
@action
handleCreate(nameInput) {
let potentialTagName = nameInput.trim();