diff --git a/js/id/modes/select.js b/js/id/modes/select.js index c85172a4a..d091fdc57 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -87,11 +87,12 @@ iD.modes.Select = function (entity) { // Exit mode if selected entity gets undone mode.history.on('change.entity-undone', function() { + var old = entity; entity = mode.history.graph().entity(entity.id); if (!entity) { mode.controller.enter(iD.modes.Browse()); - } else { - d3.select('.inspector-wrap').datum(entity).call(inspector); + } else if(!_.isEqual(entity.tags, old.tags)) { + inspector.tags(entity.tags); } }); diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js index dcae12d55..a1aed91ec 100644 --- a/js/id/ui/inspector.js +++ b/js/id/ui/inspector.js @@ -99,7 +99,8 @@ iD.ui.inspector = function() { tags = [{key: '', value: ''}]; } - var li = tagList.selectAll('li') + var li = tagList.html('') + .selectAll('li') .data(tags, function(d) { return d.key; }); li.exit().remove(); @@ -154,7 +155,6 @@ iD.ui.inspector = function() { if (en.on_node) types.push('point'); if (en.on_way) types.push('line'); en.types = types; - console.log(en); iD.ui.modal() .select('.content') .datum(en) @@ -256,15 +256,19 @@ iD.ui.inspector = function() { event.close(entity); } - inspector.tags = function () { - var tags = {}; - tagList.selectAll('li').each(function() { - var row = d3.select(this), - key = row.selectAll('.key').property('value'), - value = row.selectAll('.value').property('value'); - if (key !== '') tags[key] = value; - }); - return tags; + inspector.tags = function (tags) { + if (!arguments.length) { + var tags = {}; + tagList.selectAll('li').each(function() { + var row = d3.select(this), + key = row.selectAll('.key').property('value'), + value = row.selectAll('.value').property('value'); + if (key !== '') tags[key] = value; + }); + return tags; + } else { + drawTags(tags); + } }; return d3.rebind(inspector, event, 'on');