From 898210065e7725e75d84946258d2bd54436b471c Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 16 Oct 2013 23:55:11 -0400 Subject: [PATCH] Fix issue with changing the tag right after selecting the tag's image --- static/js/graphing.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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); }