Skip to content

Commit e94897e

Browse files
committed
LayerClick sometimes breaks when the source is not a mouseevent
Fixes swisnl#132
1 parent dc1ac58 commit e94897e

File tree

6 files changed

+123
-57
lines changed

6 files changed

+123
-57
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
* `events.activated` is called without `options`as argument ([Issue #580](https://github.com/swisnl/jQuery-contextMenu/issues/580)).
88

9+
* LayerClick sometimes breaks when the source is not a mouseevent ([Issue #132](https://github.com/swisnl/jQuery-contextMenu/issues/132)).
10+
911
### 2.6.3
1012

1113
#### Fixed

dist/jquery.contextMenu.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* Authors: Björn Brala (SWIS.nl), Rodney Rehm, Addy Osmani (patches for FF)
77
* Web: http://swisnl.github.io/jQuery-contextMenu/
88
*
9-
* Copyright (c) 2011-2017 SWIS BV and contributors
9+
* Copyright (c) 2011-2018 SWIS BV and contributors
1010
*
1111
* Licensed under
1212
* MIT License http://www.opensource.org/licenses/mit-license
1313
*
14-
* Date: 2017-12-15T13:56:37.241Z
14+
* Date: 2018-02-20T13:26:15.719Z
1515
*/
1616

1717
// jscs:disable
@@ -449,12 +449,21 @@
449449
button = e.button,
450450
x = e.pageX,
451451
y = e.pageY,
452+
fakeClick = x === undefined,
452453
target,
453454
offset;
454455

455456
e.preventDefault();
456457

457458
setTimeout(function () {
459+
// If the click is not real, things break: https://github.com/swisnl/jQuery-contextMenu/issues/132
460+
if(fakeClick){
461+
if (root !== null && typeof root !== 'undefined' && root.$menu !== null && typeof root.$menu !== 'undefined') {
462+
root.$menu.trigger('contextmenu:hide');
463+
}
464+
return;
465+
}
466+
458467
var $window;
459468
var triggerAction = ((root.trigger === 'left' && button === 0) || (root.trigger === 'right' && button === 2));
460469

dist/jquery.contextMenu.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.contextMenu.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jquery.contextMenu.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,21 @@
449449
button = e.button,
450450
x = e.pageX,
451451
y = e.pageY,
452+
fakeClick = x === undefined,
452453
target,
453454
offset;
454455

455456
e.preventDefault();
456457

457458
setTimeout(function () {
459+
// If the click is not real, things break: https://github.com/swisnl/jQuery-contextMenu/issues/132
460+
if(fakeClick){
461+
if (root !== null && typeof root !== 'undefined' && root.$menu !== null && typeof root.$menu !== 'undefined') {
462+
root.$menu.trigger('contextmenu:hide');
463+
}
464+
return;
465+
}
466+
458467
var $window;
459468
var triggerAction = ((root.trigger === 'left' && button === 0) || (root.trigger === 'right' && button === 2));
460469

yarn.lock

Lines changed: 99 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,28 @@ anchor-markdown-header@^0.5.5:
8383
dependencies:
8484
emoji-regex "~6.1.0"
8585

86+
ansi-cyan@^0.1.1:
87+
version "0.1.1"
88+
resolved "https://registry.yarnpkg.com/ansi-cyan/-/ansi-cyan-0.1.1.tgz#538ae528af8982f28ae30d86f2f17456d2609873"
89+
dependencies:
90+
ansi-wrap "0.1.0"
91+
8692
ansi-escapes@^3.0.0:
8793
version "3.0.0"
8894
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92"
8995

96+
ansi-gray@^0.1.1:
97+
version "0.1.1"
98+
resolved "https://registry.yarnpkg.com/ansi-gray/-/ansi-gray-0.1.1.tgz#2962cf54ec9792c48510a3deb524436861ef7251"
99+
dependencies:
100+
ansi-wrap "0.1.0"
101+
102+
ansi-red@^0.1.1:
103+
version "0.1.1"
104+
resolved "https://registry.yarnpkg.com/ansi-red/-/ansi-red-0.1.1.tgz#8c638f9d1080800a353c9c28c8a81ca4705d946c"
105+
dependencies:
106+
ansi-wrap "0.1.0"
107+
90108
ansi-regex@^0.2.0, ansi-regex@^0.2.1:
91109
version "0.2.1"
92110
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9"
@@ -117,6 +135,10 @@ ansi-styles@~1.0.0:
117135
version "1.0.0"
118136
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.0.0.tgz#cb102df1c56f5123eab8b67cd7b98027a0279178"
119137

138+
ansi-wrap@0.1.0:
139+
version "0.1.0"
140+
resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf"
141+
120142
anymatch@^1.3.0:
121143
version "1.3.2"
122144
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a"
@@ -183,6 +205,13 @@ argparse@^1.0.2, argparse@^1.0.6:
183205
dependencies:
184206
sprintf-js "~1.0.2"
185207

208+
arr-diff@^1.0.1:
209+
version "1.1.0"
210+
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-1.1.0.tgz#687c32758163588fef7de7b36fabe495eb1a399a"
211+
dependencies:
212+
arr-flatten "^1.0.1"
213+
array-slice "^0.2.3"
214+
186215
arr-diff@^2.0.0:
187216
version "2.0.0"
188217
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
@@ -193,6 +222,10 @@ arr-flatten@^1.0.1:
193222
version "1.1.0"
194223
resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1"
195224

225+
arr-union@^2.0.1:
226+
version "2.1.0"
227+
resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-2.1.0.tgz#20f9eab5ec70f5c7d215b1077b1c39161d292c7d"
228+
196229
array-differ@^1.0.0:
197230
version "1.0.0"
198231
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031"
@@ -269,10 +302,6 @@ async@0.2.x, async@~0.2.9:
269302
version "0.2.10"
270303
resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1"
271304

272-
async@1.4.0:
273-
version "1.4.0"
274-
resolved "https://registry.yarnpkg.com/async/-/async-1.4.0.tgz#35f86f83c59e0421d099cd9a91d8278fb578c00d"
275-
276305
async@2.0.1:
277306
version "2.0.1"
278307
resolved "https://registry.yarnpkg.com/async/-/async-2.0.1.tgz#b709cc0280a9c36f09f4536be823c838a9049e25"
@@ -709,6 +738,10 @@ color-name@^1.1.1:
709738
version "1.1.3"
710739
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
711740

741+
color-support@^1.1.3:
742+
version "1.1.3"
743+
resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2"
744+
712745
colors@0.6.x:
713746
version "0.6.2"
714747
resolved "https://registry.yarnpkg.com/colors/-/colors-0.6.2.tgz#2423fe6678ac0c5dae8852e5d0e5be08c997abcc"
@@ -1389,6 +1422,12 @@ ext-map@^1.0.0:
13891422
version "1.0.1"
13901423
resolved "https://registry.yarnpkg.com/ext-map/-/ext-map-1.0.1.tgz#1fcd857135694bb229fbdccf2614db60d813e051"
13911424

1425+
extend-shallow@^1.1.2:
1426+
version "1.1.4"
1427+
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-1.1.4.tgz#19d6bf94dfc09d76ba711f39b872d21ff4dd9071"
1428+
dependencies:
1429+
kind-of "^1.1.0"
1430+
13921431
extend-shallow@^2.0.1:
13931432
version "2.0.1"
13941433
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
@@ -1437,6 +1476,14 @@ fancy-log@^1.1.0, fancy-log@^1.2.0:
14371476
chalk "^1.1.1"
14381477
time-stamp "^1.0.0"
14391478

1479+
fancy-log@^1.3.2:
1480+
version "1.3.2"
1481+
resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.2.tgz#f41125e3d84f2e7d89a43d06d958c8f78be16be1"
1482+
dependencies:
1483+
ansi-gray "^0.1.1"
1484+
color-support "^1.1.3"
1485+
time-stamp "^1.0.0"
1486+
14401487
fast-deep-equal@^1.0.0:
14411488
version "1.0.0"
14421489
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff"
@@ -1754,7 +1801,7 @@ glob@^4.3.1:
17541801
minimatch "^2.0.1"
17551802
once "^1.3.0"
17561803

1757-
glob@^5.0.1, glob@^5.0.14:
1804+
glob@^5.0.1:
17581805
version "5.0.15"
17591806
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"
17601807
dependencies:
@@ -1992,15 +2039,16 @@ gulp-load-plugins@^1.3.0:
19922039
micromatch "^2.3.8"
19932040
resolve "^1.1.7"
19942041

1995-
gulp-qunit@^1.5.0:
1996-
version "1.5.2"
1997-
resolved "https://registry.yarnpkg.com/gulp-qunit/-/gulp-qunit-1.5.2.tgz#d6799044a278b2dd00eb74b8ce2ca89586e9e12a"
2042+
gulp-qunit@^2.0.0:
2043+
version "2.0.1"
2044+
resolved "https://registry.yarnpkg.com/gulp-qunit/-/gulp-qunit-2.0.1.tgz#424996c0b79fc0866b895fcba69ade7679c5a26d"
19982045
dependencies:
19992046
chalk "^2.2.0"
2000-
gulp-util "^3.0.0"
2047+
fancy-log "^1.3.2"
20012048
phantomjs-prebuilt "^2.1.3"
2049+
plugin-error "^0.1.2"
20022050
qunit-phantomjs-runner "^2.2.0"
2003-
through2 "0.6.5"
2051+
through2 "^2.0.3"
20042052

20052053
gulp-rename@^1.2.2:
20062054
version "1.2.2"
@@ -2795,14 +2843,14 @@ karma-qunit@^1.2.1:
27952843
version "1.2.1"
27962844
resolved "https://registry.yarnpkg.com/karma-qunit/-/karma-qunit-1.2.1.tgz#88252afd2127bc03b0cc31978ed6882b139f470a"
27972845

2798-
karma-sauce-launcher@1.1.0:
2799-
version "1.1.0"
2800-
resolved "https://registry.yarnpkg.com/karma-sauce-launcher/-/karma-sauce-launcher-1.1.0.tgz#3d083cf5659d6736ab97bcee5d8acd86ad522212"
2846+
karma-sauce-launcher@1.2.0:
2847+
version "1.2.0"
2848+
resolved "https://registry.yarnpkg.com/karma-sauce-launcher/-/karma-sauce-launcher-1.2.0.tgz#6f2558ddef3cf56879fa27540c8ae9f8bfd16bca"
28012849
dependencies:
2802-
q "^1.4.1"
2803-
sauce-connect-launcher "^0.17.0"
2804-
saucelabs "^1.3.0"
2805-
wd "^1.0.0"
2850+
q "^1.5.0"
2851+
sauce-connect-launcher "^1.2.2"
2852+
saucelabs "^1.4.0"
2853+
wd "^1.4.0"
28062854

28072855
karma@^1.3.0:
28082856
version "1.7.1"
@@ -2840,6 +2888,10 @@ kew@^0.7.0:
28402888
version "0.7.0"
28412889
resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b"
28422890

2891+
kind-of@^1.1.0:
2892+
version "1.1.0"
2893+
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-1.1.0.tgz#140a3d2d41a36d2efcfa9377b62c24f8495a5c44"
2894+
28432895
kind-of@^2.0.0, kind-of@^2.0.1:
28442896
version "2.0.1"
28452897
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-2.0.1.tgz#018ec7a4ce7e3a86cb9141be519d24c8faa981b5"
@@ -3141,10 +3193,6 @@ lodash.values@~2.4.1:
31413193
dependencies:
31423194
lodash.keys "~2.4.1"
31433195

3144-
lodash@3.10.1, lodash@^3.0.1, lodash@^3.5.0, lodash@^3.7.0, lodash@^3.8.0, lodash@~3.10.0:
3145-
version "3.10.1"
3146-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
3147-
31483196
lodash@3.7.x:
31493197
version "3.7.0"
31503198
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.7.0.tgz#3678bd8ab995057c07ade836ed2ef087da811d45"
@@ -3153,6 +3201,10 @@ lodash@4.16.2:
31533201
version "4.16.2"
31543202
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.2.tgz#3e626db827048a699281a8a125226326cfc0e652"
31553203

3204+
lodash@^3.0.1, lodash@^3.5.0, lodash@^3.7.0, lodash@^3.8.0, lodash@~3.10.0:
3205+
version "3.10.1"
3206+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
3207+
31563208
lodash@^4.0.0, lodash@^4.0.1, lodash@^4.12.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.16.4, lodash@^4.16.6, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.0, lodash@^4.6.1, lodash@^4.8.0, lodash@~4.17.4:
31573209
version "4.17.4"
31583210
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
@@ -3878,6 +3930,16 @@ plexer@1.0.1, plexer@^1.0.1:
38783930
isstream "^0.1.2"
38793931
readable-stream "^2.0.2"
38803932

3933+
plugin-error@^0.1.2:
3934+
version "0.1.2"
3935+
resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-0.1.2.tgz#3b9bb3335ccf00f425e07437e19276967da47ace"
3936+
dependencies:
3937+
ansi-cyan "^0.1.1"
3938+
ansi-red "^0.1.1"
3939+
arr-diff "^1.0.1"
3940+
arr-union "^2.0.1"
3941+
extend-shallow "^1.1.2"
3942+
38813943
plur@^2.0.0:
38823944
version "2.1.2"
38833945
resolved "https://registry.yarnpkg.com/plur/-/plur-2.1.2.tgz#7482452c1a0f508e3e344eaec312c91c29dc655a"
@@ -3926,9 +3988,9 @@ pseudomap@^1.0.2:
39263988
version "1.0.2"
39273989
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
39283990

3929-
pump@^1.0.2:
3930-
version "1.0.3"
3931-
resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954"
3991+
pump@^2.0.0:
3992+
version "2.0.1"
3993+
resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909"
39323994
dependencies:
39333995
end-of-stream "^1.1.0"
39343996
once "^1.3.1"
@@ -3945,7 +4007,7 @@ q@1.4.1:
39454007
version "1.4.1"
39464008
resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e"
39474009

3948-
q@^1.4.1, q@~1.5.0:
4010+
q@^1.5.0, q@~1.5.0:
39494011
version "1.5.1"
39504012
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
39514013

@@ -4368,12 +4430,6 @@ rimraf@2, rimraf@2.x.x, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6
43684430
dependencies:
43694431
glob "^7.0.5"
43704432

4371-
rimraf@2.4.3:
4372-
version "2.4.3"
4373-
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.4.3.tgz#e5b51c9437a4c582adb955e9f28cf8d945e272af"
4374-
dependencies:
4375-
glob "^5.0.14"
4376-
43774433
run-async@^2.2.0:
43784434
version "2.3.0"
43794435
resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0"
@@ -4403,17 +4459,7 @@ sass-graph@^2.2.4:
44034459
scss-tokenizer "^0.2.3"
44044460
yargs "^7.0.0"
44054461

4406-
sauce-connect-launcher@^0.17.0:
4407-
version "0.17.0"
4408-
resolved "https://registry.yarnpkg.com/sauce-connect-launcher/-/sauce-connect-launcher-0.17.0.tgz#908d9311ecaf17dd9b4647a1435fd4a2072e80ce"
4409-
dependencies:
4410-
adm-zip "~0.4.3"
4411-
async "1.4.0"
4412-
https-proxy-agent "~1.0.0"
4413-
lodash "3.10.1"
4414-
rimraf "2.4.3"
4415-
4416-
sauce-connect-launcher@~1.2.3:
4462+
sauce-connect-launcher@^1.2.2, sauce-connect-launcher@~1.2.3:
44174463
version "1.2.3"
44184464
resolved "https://registry.yarnpkg.com/sauce-connect-launcher/-/sauce-connect-launcher-1.2.3.tgz#d2f931ad7ae8fdabf1968a440e7b20417aca7f86"
44194465
dependencies:
@@ -4423,7 +4469,7 @@ sauce-connect-launcher@~1.2.3:
44234469
lodash "^4.16.6"
44244470
rimraf "^2.5.4"
44254471

4426-
saucelabs@^1.3.0:
4472+
saucelabs@^1.4.0:
44274473
version "1.4.0"
44284474
resolved "https://registry.yarnpkg.com/saucelabs/-/saucelabs-1.4.0.tgz#b934a9af9da2874b3f40aae1fcde50a4466f5f38"
44294475
dependencies:
@@ -4909,13 +4955,6 @@ throttleit@^1.0.0:
49094955
version "1.0.0"
49104956
resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c"
49114957

4912-
through2@0.6.5, through2@^0.6.1:
4913-
version "0.6.5"
4914-
resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48"
4915-
dependencies:
4916-
readable-stream ">=1.0.33-1 <1.1.0-0"
4917-
xtend ">=4.0.0 <4.1.0-0"
4918-
49194958
through2@2.0.3, through2@2.X, through2@^2.0.0, through2@^2.0.1, through2@^2.0.3:
49204959
version "2.0.3"
49214960
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
@@ -4930,6 +4969,13 @@ through2@^0.5.0:
49304969
readable-stream "~1.0.17"
49314970
xtend "~3.0.0"
49324971

4972+
through2@^0.6.1:
4973+
version "0.6.5"
4974+
resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48"
4975+
dependencies:
4976+
readable-stream ">=1.0.33-1 <1.1.0-0"
4977+
xtend ">=4.0.0 <4.1.0-0"
4978+
49334979
through@^2.3.6:
49344980
version "2.3.8"
49354981
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
@@ -5354,9 +5400,9 @@ walkdir@^0.0.11:
53545400
version "0.0.11"
53555401
resolved "https://registry.yarnpkg.com/walkdir/-/walkdir-0.0.11.tgz#a16d025eb931bd03b52f308caed0f40fcebe9532"
53565402

5357-
wd@^1.0.0:
5358-
version "1.4.1"
5359-
resolved "https://registry.yarnpkg.com/wd/-/wd-1.4.1.tgz#6b1ab39aab1728ee276c1a2b6d7321da68b16e8c"
5403+
wd@^1.4.0:
5404+
version "1.5.0"
5405+
resolved "https://registry.yarnpkg.com/wd/-/wd-1.5.0.tgz#45c96a16ff9f8c0f9e7ca90f806a8b48bd0034d6"
53605406
dependencies:
53615407
archiver "1.3.0"
53625408
async "2.0.1"

0 commit comments

Comments
 (0)