diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 03804e1bc..b25969ec7 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -374,7 +374,8 @@ iD.Map = function(elem, connection) { } inspector.on('changeTags', function(d, tags) { - map.perform(iD.actions.changeTags(d, tags)); + var entity = map.history.graph().entity(d.id); + map.perform(iD.actions.changeTags(entity, tags)); }).on('changeWayDirection', function(d, tags) { map.perform(iD.actions.changeWayDirection(d)); }).on('remove', function(d) { diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js index 79adeef94..0344bf0cd 100644 --- a/js/id/ui/inspector.js +++ b/js/id/ui/inspector.js @@ -83,18 +83,27 @@ iD.Inspector = function() { }); } - function update() { + function clean(x) { + for (var i in x) if (!i) delete x[i]; + return x; + } + + function pad(x) { + if (!x['']) x[''] = ''; + return x; + } + + function grabtags() { var grabbed = {}; function grab(d) { grabbed[d.key] = d.value; } tbody.selectAll('td').each(grab); - if (!grabbed['']) { - grabbed[''] = ''; - draw(grabbed); - } - draw(grabbed); return grabbed; } + function update() { + draw(pad(grabtags())); + } + var data = _.clone(entity.tags); draw(data); update(); @@ -102,7 +111,7 @@ iD.Inspector = function() { selection.append('button') .attr('class', 'save').text('Save') .on('click', function() { - event.changeTags(entity, update()); + event.changeTags(entity, clean(grabtags())); }); selection.append('button')