FIX: alphabetical tag sorting in mini-tag-chooser

This commit is contained in:
Penar Musaraj 2019-12-10 12:36:49 -05:00
parent 31c6a1528b
commit ba8d8a4f93
2 changed files with 9 additions and 3 deletions

View File

@ -218,7 +218,7 @@ export default ComboBox.extend(TagsMixin, {
context.set("termMatchErrorMessage", json.forbidden_message);
if (context.get("siteSettings.tags_sort_alphabetically")) {
results = results.sort((a, b) => a.id > b.id);
results = results.sort((a, b) => a.text.localeCompare(b.text));
}
results = results.filter(r => !context.get("selection").includes(r.id));

View File

@ -14,6 +14,7 @@ componentTest("default", {
beforeEach() {
this.siteSettings.max_tag_length = 24;
this.siteSettings.force_lowercase_tags = true;
this.siteSettings.tags_sort_alphabetically = true;
this.site.set("can_create_tag", true);
this.set("tags", ["jeff", "neil", "arpit"]);
@ -35,11 +36,10 @@ componentTest("default", {
}
return response({
results: [{ text: "bianca", count: 3 }, { text: "régis", count: 5 }]
results: [{ text: "penar", count: 3 }, { text: "bianca", count: 3 }, { text: "régis", count: 5 }]
});
});
},
skip: true,
async test(assert) {
await this.subject.expand();
@ -51,6 +51,12 @@ componentTest("default", {
assert.equal(
this.subject.rowByIndex(1).name(),
"penar",
"it has the correct tag at the correct position after alphabetical sorting"
);
assert.equal(
this.subject.rowByIndex(2).name(),
"régis",
"it has the correct tag"
);