From 36a767554c981fce73d8b42dce6726f7b0e036a1 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sun, 7 Feb 2016 00:46:12 -0500 Subject: [PATCH] Allow escape to cancel paste (closes #2889) --- js/id/behavior/paste.js | 5 +++-- js/id/modes/move.js | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/js/id/behavior/paste.js b/js/id/behavior/paste.js index 5d4a71a2b..ada7c1d90 100644 --- a/js/id/behavior/paste.js +++ b/js/id/behavior/paste.js @@ -21,7 +21,8 @@ iD.behavior.Paste = function(context) { d3.event.preventDefault(); if (context.inIntro()) return; - var mouse = context.mouse(), + var baseGraph = context.graph(), + mouse = context.mouse(), projection = context.projection, viewport = iD.geo.Extent(projection.clipExtent()).polygon(); @@ -61,7 +62,7 @@ iD.behavior.Paste = function(context) { delta = [ mouse[0] - center[0], mouse[1] - center[1] ]; context.perform(iD.actions.Move(newIDs, delta, projection)); - context.enter(iD.modes.Move(context, newIDs)); + context.enter(iD.modes.Move(context, newIDs, baseGraph)); } function paste() { diff --git a/js/id/modes/move.js b/js/id/modes/move.js index b564fde8f..ccae9cd50 100644 --- a/js/id/modes/move.js +++ b/js/id/modes/move.js @@ -1,4 +1,4 @@ -iD.modes.Move = function(context, entityIDs) { +iD.modes.Move = function(context, entityIDs, baseGraph) { var mode = { id: 'move', button: 'browse' @@ -64,8 +64,13 @@ iD.modes.Move = function(context, entityIDs) { } function cancel() { - context.pop(); - context.enter(iD.modes.Select(context, entityIDs).suppressMenu(true)); + if (baseGraph) { + while (context.graph() !== baseGraph) context.pop(); + context.enter(iD.modes.Browse(context)); + } else { + context.pop(); + context.enter(iD.modes.Select(context, entityIDs).suppressMenu(true)); + } stopNudge(); }