diff --git a/static/js/graphing.js b/static/js/graphing.js index bb776d816..ba371fba4 100644 --- a/static/js/graphing.js +++ b/static/js/graphing.js @@ -367,14 +367,23 @@ ImageHistoryTree.prototype.markPath_ = function(startingNode, isHighlighted) { * Sets the current tag displayed in the tree. */ ImageHistoryTree.prototype.setTag_ = function(tagName) { + if (tagName == this.currentTag_) { + return; + } + + var imageByDBID = this.imageByDBID_; + // Save the current tag. + var previousTagName = this.currentTag_; this.currentTag_ = tagName; - var imageByDBID = this.imageByDBID_; - // Update the state of each existing node to no longer be highlighted. - if (this.currentImage_) { - var currentNode = imageByDBID[this.currentImage_.dbid]; + var previousImage = this.findImage_(function(image) { + return image.tags.indexOf(previousTagName || '(no tag specified)') >= 0; + }); + + if (previousImage) { + var currentNode = imageByDBID[previousImage.dbid]; this.markPath_(currentNode, false); }