commit be04f3d33cae3564f2f2e26dc0b77fa2ce4a1998
parent 9ffcd8930354ea1fbe0d9806ea938d01f86ae2a7
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 15 Mar 2016 01:16:36 -0400
Restore colored tags at top of tag selector when not linked to item
Diffstat:
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml
@@ -244,6 +244,13 @@
.tap(() => Zotero.Promise.check(this.mode));
tagsBox.textContent = "";
+ // Add colored tags that aren't already real tags
+ let regularTags = new Set(this._tags.map(tag => tag.tag));
+ let coloredTags = new Set(tagColors.keys());
+ [for (x of coloredTags) if (!regularTags.has(x)) x].forEach(x =>
+ this._tags.push(Zotero.Tags.cleanData({ tag: x }))
+ );
+
// Sort by name
let collation = Zotero.getLocaleCollation();
this._tags.sort(function (a, b) {
diff --git a/test/tests/tagSelectorTest.js b/test/tests/tagSelectorTest.js
@@ -155,6 +155,18 @@ describe("Tag Selector", function () {
assert.equal(getRegularTags().length, 1);
})
+ it("should show a colored tag at the top of the list even when linked to no items", function* () {
+ var libraryID = Zotero.Libraries.userLibraryID;
+
+ var tagSelector = doc.getElementById('zotero-tag-selector');
+ var tagElems = tagSelector.id('tags-box').childNodes;
+ var count = tagElems.length;
+
+ yield Zotero.Tags.setColor(libraryID, "Top", '#AAAAAA');
+
+ assert.equal(tagElems.length, count + 1);
+ });
+
it("shouldn't re-insert a new tag that matches an existing color", function* () {
var libraryID = Zotero.Libraries.userLibraryID;