Exit select mode if selected DOM elements have disappeared

This commit is contained in:
Bryan Housel
2014-11-10 23:23:28 -05:00
parent af3c307b17
commit 2024e2333d
3 changed files with 14 additions and 15 deletions

View File

@@ -205,7 +205,7 @@ window.iD = function () {
context.background = function() { return background; }; context.background = function() { return background; };
/* Features */ /* Features */
var features = iD.Features(context); var features = iD.Features();
context.features = function() { return features; }; context.features = function() { return features; };
context.hasHiddenConnections = function(id) { context.hasHiddenConnections = function(id) {
var graph = history.graph(), var graph = history.graph(),

View File

@@ -137,9 +137,16 @@ iD.modes.Select = function(context, selectedIDs) {
.call(keybinding); .call(keybinding);
function selectElements() { function selectElements() {
context.surface() var selection = context.surface()
.selectAll(iD.util.entityOrMemberSelector(selectedIDs, context.graph())) .selectAll(iD.util.entityOrMemberSelector(selectedIDs, context.graph()));
.classed('selected', true);
if (selection.empty()) {
// Exit mode if selected DOM elements have disappeared..
context.enter(iD.modes.Browse(context));
} else {
selection
.classed('selected', true);
}
} }
context.map().on('drawn.select', selectElements); context.map().on('drawn.select', selectElements);

View File

@@ -1,4 +1,4 @@
iD.Features = function(context) { iD.Features = function() {
var major_roads = { var major_roads = {
'motorway': true, 'motorway': true,
'motorway_link': true, 'motorway_link': true,
@@ -378,21 +378,13 @@ iD.Features = function(context) {
}; };
features.filter = function(d, resolver) { features.filter = function(d, resolver) {
var selected = context.selectedIDs(), var result = [];
result = [];
if (!_hidden.length) { if (!_hidden.length) {
return d; return d;
} else { } else {
for (var i = 0, imax = d.length; i !== imax; i++) { for (var i = 0, imax = d.length; i !== imax; i++) {
if (features.isHidden(d[i], resolver)) { if (!features.isHidden(d[i], resolver)) {
for (var j = 0, jmax = selected.length; j !== jmax; j++) {
if (selected[j] === d[i].id) {
context.enter(iD.modes.Browse(context));
break;
}
}
} else {
result.push(d[i]); result.push(d[i]);
} }
} }