From 902c122383e51243f2821a3fdc9b478ee32b0d45 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 22 Dec 2015 16:23:18 -0500 Subject: [PATCH] Cancel throttled hover events when exiting hover modes possibly related to #2736, as a source of "Uncaught Error Entity xxxx not found" errors --- js/id/behavior/draw.js | 1 + js/id/modes/browse.js | 1 + js/id/modes/drag_node.js | 1 + js/id/ui/sidebar.js | 9 +++++---- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/js/id/behavior/draw.js b/js/id/behavior/draw.js index 71dfd7b5f..87027fb31 100644 --- a/js/id/behavior/draw.js +++ b/js/id/behavior/draw.js @@ -116,6 +116,7 @@ iD.behavior.Draw = function(context) { } draw.off = function(selection) { + context.ui().sidebar.hover.cancel(); context.uninstall(hover); context.uninstall(edit); diff --git a/js/id/modes/browse.js b/js/id/modes/browse.js index d057cbbf6..1300142f8 100644 --- a/js/id/modes/browse.js +++ b/js/id/modes/browse.js @@ -32,6 +32,7 @@ iD.modes.Browse = function(context) { }; mode.exit = function() { + context.ui().sidebar.hover.cancel(); behaviors.forEach(function(behavior) { context.uninstall(behavior); }); diff --git a/js/id/modes/drag_node.js b/js/id/modes/drag_node.js index 3388eaa3c..50f89e1d0 100644 --- a/js/id/modes/drag_node.js +++ b/js/id/modes/drag_node.js @@ -186,6 +186,7 @@ iD.modes.DragNode = function(context) { }; mode.exit = function() { + context.ui().sidebar.hover.cancel(); context.uninstall(hover); context.uninstall(edit); diff --git a/js/id/ui/sidebar.js b/js/id/ui/sidebar.js index 0f6736a31..4d7c726d6 100644 --- a/js/id/ui/sidebar.js +++ b/js/id/ui/sidebar.js @@ -12,8 +12,8 @@ iD.ui.Sidebar = function(context) { var inspectorWrap = selection.append('div') .attr('class', 'inspector-hidden inspector-wrap fr'); - sidebar.hover = function(id) { - if (!current && id) { + function hover(id) { + if (!current && context.hasEntity(id)) { featureListWrap.classed('inspector-hidden', true); inspectorWrap.classed('inspector-hidden', false) .classed('inspector-hover', true); @@ -30,9 +30,9 @@ iD.ui.Sidebar = function(context) { inspectorWrap.classed('inspector-hidden', true); inspector.state('hide'); } - }; + } - sidebar.hover = _.throttle(sidebar.hover, 200); + sidebar.hover = _.throttle(hover, 200); sidebar.select = function(id, newFeature) { if (!current && id) { @@ -73,6 +73,7 @@ iD.ui.Sidebar = function(context) { } sidebar.hover = function() {}; + sidebar.hover.cancel = function() {}; sidebar.select = function() {}; sidebar.show = function() {}; sidebar.hide = function() {};