From a515aa30a1fa6621711c16a54f3c516bc78931eb Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 6 Apr 2015 20:27:04 +0300 Subject: client: fix broken node and link deletion, plus fix selection after both --- src/client/view/selection.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/client/view/selection.js') diff --git a/src/client/view/selection.js b/src/client/view/selection.js index 6f7d24b4..fcf46258 100644 --- a/src/client/view/selection.js +++ b/src/client/view/selection.js @@ -61,14 +61,14 @@ function listen_on_diff_bus(diffBus) diffBus .onValue(function (diff) { // update due to potentially removed nodes first - root_nodes = root_nodes.filter(function (n) { + new_root_nodes = root_nodes.filter(function (n) { return get_main_graph().find_node__by_id(n.id) !== null; }); - selected_nodes = selected_nodes.filter(function (n) { + new_selected_nodes = selected_nodes.filter(function (n) { return get_main_graph().find_node__by_id(n.id) !== null; }); // reselect based on current graph - inner_select(root_nodes, selected_nodes); + inner_select(new_root_nodes, new_selected_nodes); }); } @@ -188,7 +188,7 @@ var node_root_selected = function(node) { } var node_first_selected = function(node) { - return node.id === root_nodes[0].id; + return root_nodes && root_nodes.length > 0 && node.id === root_nodes[0].id; } var link_selected = function(link) { -- cgit v1.3.1