diff --git a/js/id/modes/add_point.js b/js/id/modes/add_point.js index 21d6343e0..82ad283c2 100644 --- a/js/id/modes/add_point.js +++ b/js/id/modes/add_point.js @@ -19,7 +19,7 @@ iD.modes.AddPoint = function() { iD.actions.AddNode(node), 'added a point'); - controller.enter(iD.modes.Select(node)); + controller.enter(iD.modes.Select(node, true)); }); map.keybinding().on('⎋.addpoint', function() { diff --git a/js/id/modes/draw_area.js b/js/id/modes/draw_area.js index 196a4de53..2f1fa6304 100644 --- a/js/id/modes/draw_area.js +++ b/js/id/modes/draw_area.js @@ -43,7 +43,7 @@ iD.modes.DrawArea = function(wayId) { if (datum.id === tailId || datum.id === headId) { if (way.nodes.length > 3) { history.undo(); - controller.enter(iD.modes.Select(way)); + controller.enter(iD.modes.Select(way, true)); } else { // Areas with less than 3 nodes gets deleted history.replace(iD.actions.DeleteWay(way.id)); @@ -94,7 +94,7 @@ iD.modes.DrawArea = function(wayId) { function ret() { d3.event.preventDefault(); history.replace(iD.actions.DeleteNode(node.id)); - controller.enter(iD.modes.Select(way)); + controller.enter(iD.modes.Select(way, true)); } surface diff --git a/js/id/modes/draw_line.js b/js/id/modes/draw_line.js index 4be2e5527..8442fbf80 100644 --- a/js/id/modes/draw_line.js +++ b/js/id/modes/draw_line.js @@ -48,7 +48,7 @@ iD.modes.DrawLine = function(wayId, direction) { iD.actions.AddWayNode(wayId, tailId, index), 'added to a line'); - controller.enter(iD.modes.Select(way)); + controller.enter(iD.modes.Select(way, true)); } else { history.replace(iD.actions.DeleteWay(way.id)); @@ -59,7 +59,7 @@ iD.modes.DrawLine = function(wayId, direction) { // finish the way history.undo(); - controller.enter(iD.modes.Select(way)); + controller.enter(iD.modes.Select(way, true)); } else if (datum.type === 'node' && datum.id !== node.id) { // connect the way to an existing node @@ -71,13 +71,14 @@ iD.modes.DrawLine = function(wayId, direction) { controller.enter(iD.modes.DrawLine(wayId, direction)); } else if (datum.type === 'way' || datum.midpoint) { + var choice; // connect the way to an existing way if (datum.midpoint) { // if clicked on midpoint datum.id = datum.way; choice = datum; } else { - var choice = iD.util.geo.chooseIndex(datum, d3.mouse(surface.node()), map); + choice = iD.util.geo.chooseIndex(datum, d3.mouse(surface.node()), map); } history.replace( @@ -120,7 +121,7 @@ iD.modes.DrawLine = function(wayId, direction) { function ret() { d3.event.preventDefault(); history.replace(iD.actions.DeleteNode(node.id)); - controller.enter(iD.modes.Select(way)); + controller.enter(iD.modes.Select(way, true)); } function undo() { diff --git a/js/id/modes/select.js b/js/id/modes/select.js index add2e3750..883acacb1 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -1,11 +1,11 @@ -iD.modes.Select = function(entity) { +iD.modes.Select = function(entity, initial) { var mode = { id: 'select', button: 'browse', entity: entity }; - var inspector = iD.ui.inspector(), + var inspector = iD.ui.inspector().initial(!!initial), behaviors; function remove() { diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js index aa3ad3add..7837ba21f 100644 --- a/js/id/ui/inspector.js +++ b/js/id/ui/inspector.js @@ -2,6 +2,7 @@ iD.ui.inspector = function() { var event = d3.dispatch('changeTags', 'changeWayDirection', 'update', 'remove', 'close', 'splitWay'), taginfo = iD.taginfo(), + initial = false, tagList; function inspector(selection) { @@ -194,7 +195,8 @@ iD.ui.inspector = function() { helpBtn.append('span') .attr('class', 'icon inspect'); - if (tags.length === 1 && tags[0].key === '' && tags[0].value === '') { + if (initial && tags.length === 1 && + tags[0].key === '' && tags[0].value === '') { focusNewKey(); } @@ -271,7 +273,7 @@ iD.ui.inspector = function() { event.close(entity); } - inspector.tags = function (tags) { + inspector.tags = function(tags) { if (!arguments.length) { tags = {}; tagList.selectAll('li').each(function() { @@ -286,5 +288,10 @@ iD.ui.inspector = function() { } }; + inspector.initial = function(_) { + initial = _; + return inspector; + }; + return d3.rebind(inspector, event, 'on'); };