Don't let window.location changes happen during draw modes

(closes #3996)
This commit is contained in:
Bryan Housel
2017-05-03 17:15:35 -04:00
parent 651ec363f6
commit a18d690dd5
2 changed files with 17 additions and 6 deletions
+10 -3
View File
@@ -125,8 +125,15 @@ export function behaviorDrawWay(context, wayId, index, mode, startGraph) {
drawWay.off = function(surface) {
context.pop(tempEdits);
tempEdits = 0;
// Drawing was interrupted unexpectedly.
// This can happen if the user changes modes,
// clicks geolocate button, a hashchange event occurs, etc.
if (tempEdits) {
context.pop(tempEdits);
while (context.graph() !== startGraph) {
context.pop();
}
}
context.map()
.on('drawn.draw', null);
@@ -268,7 +275,7 @@ export function behaviorDrawWay(context, wayId, index, mode, startGraph) {
tempEdits = 0;
var way = context.hasEntity(wayId);
if (!way || origWay.isDegenerate()) {
if (!way || way.isDegenerate()) {
drawWay.cancel();
return;
}
+7 -3
View File
@@ -1,6 +1,7 @@
import * as d3 from 'd3';
import _ from 'lodash';
import { utilQsString, utilStringQs } from '../util/index';
import { modeBrowse } from '../modes';
import { utilQsString, utilStringQs } from '../util';
export function behaviorHash(context) {
@@ -14,8 +15,11 @@ export function behaviorHash(context) {
if (args.length < 3 || args.some(isNaN)) {
return true; // replace bogus hash
} else if (s !== formatter(map).slice(1)) {
map.centerZoom([args[2],
Math.min(lat, Math.max(-lat, args[1]))], args[0]);
var mode = context.mode();
if (mode && mode.id.match(/^draw/) !== null) {
context.enter(modeBrowse(context));
}
map.centerZoom([args[2], Math.min(lat, Math.max(-lat, args[1]))], args[0]);
}
};