Skip to content

Commit 3304b5d

Browse files
author
Stuart McGrigor
committed
Delay the event.preventDefault() on right-click to make sure we have a fn to call
1 parent 0f80014 commit 3304b5d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

angular-tree-control.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,21 @@
220220
}
221221
};
222222

223-
$scope.rightClickNodeLabel = function( targetNode ) {
223+
$scope.rightClickNodeLabel = function( targetNode, $event ) {
224224

225-
// Are are we changing the 'selected' node (as well)?
226-
if ($scope.selectedNode != targetNode) {
227-
this.selectNodeLabel( targetNode);
228-
}
229-
230-
// ...and do the rightClick
225+
// Is there a right click function??
231226
if($scope.onRightClick) {
227+
228+
// Turn off the browser default context-menu
229+
if($event)
230+
$event.preventDefault();
231+
232+
// Are are we changing the 'selected' node (as well)?
233+
if ($scope.selectedNode != targetNode) {
234+
this.selectNodeLabel(targetNode);
235+
}
236+
237+
// Finally go do what they asked
232238
$scope.onRightClick({node: targetNode});
233239
}
234240
};
@@ -336,8 +342,7 @@
336342
var fn = $parse(attrs.treeRightClick);
337343
element.bind('contextmenu', function(event) {
338344
scope.$apply(function() {
339-
event.preventDefault(); // Don't show the browser's normal context menu
340-
fn(scope, {$event:event}); // go do our stuff
345+
fn(scope, {$event:event}); // go do our stuff
341346
});
342347
});
343348
};

0 commit comments

Comments
 (0)