From be04f3d33cae3564f2f2e26dc0b77fa2ce4a1998 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 15 Mar 2016 01:16:36 -0400 Subject: [PATCH] Restore colored tags at top of tag selector when not linked to item --- chrome/content/zotero/bindings/tagselector.xml | 7 +++++++ test/tests/tagSelectorTest.js | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml index e2334fc01..03bb70a42 100644 --- 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 index 4a8f09d0a..957b0af7f 100644 --- 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;