Skip to content

Commit d78b303

Browse files
committed
fixing can't close menu regression
1 parent 9516d56 commit d78b303

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ $.contextMenu is published under the [MIT license](http://www.opensource.org/lic
103103

104104
## Changelog ##
105105

106+
### 1.6.2 (January 19th 2013) ###
107+
108+
* fixing "menu won't close" regression introduced by 1.6.1
109+
106110
### 1.6.1 (January 19th 2013) ###
107111

108112
* fixing potential html parsing problem

src/jquery.contextMenu.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ var // currently active contextMenu trigger
355355

356356
setTimeout(function() {
357357
var $window, hideshow, possibleTarget;
358+
var triggerAction = ((root.trigger == 'left' && button === 0) || (root.trigger == 'right' && button === 2));
358359

359360
// find the element that would've been clicked, wasn't the layer in the way
360361
if (document.elementFromPoint) {
@@ -363,7 +364,7 @@ var // currently active contextMenu trigger
363364
root.$layer.show();
364365
}
365366

366-
if (root.reposition && ((root.trigger == 'left' && button == 0) || (root.trigger == 'right' && button == 2))) {
367+
if (root.reposition && triggerAction) {
367368
if (document.elementFromPoint) {
368369
if (root.$trigger.is(target) || root.$trigger.has(target).length) {
369370
root.position.call(root.$trigger, root, x, y);
@@ -391,7 +392,7 @@ var // currently active contextMenu trigger
391392
}
392393
}
393394
}
394-
if (target) {
395+
if (target && triggerAction) {
395396
$(target).contextMenu({x: x, y: y});
396397
} else {
397398
// TODO: it would be nice if we could prevent animations here

0 commit comments

Comments
 (0)