mirror of
https://github.com/discourse/discourse.git
synced 2025-06-19 22:23:04 +08:00
FIX: alphabetical tag sorting in mini-tag-chooser
This commit is contained in:
@ -218,7 +218,7 @@ export default ComboBox.extend(TagsMixin, {
|
|||||||
context.set("termMatchErrorMessage", json.forbidden_message);
|
context.set("termMatchErrorMessage", json.forbidden_message);
|
||||||
|
|
||||||
if (context.get("siteSettings.tags_sort_alphabetically")) {
|
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));
|
results = results.filter(r => !context.get("selection").includes(r.id));
|
||||||
|
@ -14,6 +14,7 @@ componentTest("default", {
|
|||||||
beforeEach() {
|
beforeEach() {
|
||||||
this.siteSettings.max_tag_length = 24;
|
this.siteSettings.max_tag_length = 24;
|
||||||
this.siteSettings.force_lowercase_tags = true;
|
this.siteSettings.force_lowercase_tags = true;
|
||||||
|
this.siteSettings.tags_sort_alphabetically = true;
|
||||||
|
|
||||||
this.site.set("can_create_tag", true);
|
this.site.set("can_create_tag", true);
|
||||||
this.set("tags", ["jeff", "neil", "arpit"]);
|
this.set("tags", ["jeff", "neil", "arpit"]);
|
||||||
@ -35,11 +36,10 @@ componentTest("default", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return response({
|
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) {
|
async test(assert) {
|
||||||
await this.subject.expand();
|
await this.subject.expand();
|
||||||
|
|
||||||
@ -51,6 +51,12 @@ componentTest("default", {
|
|||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
this.subject.rowByIndex(1).name(),
|
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",
|
"régis",
|
||||||
"it has the correct tag"
|
"it has the correct tag"
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user