@rc-component/trigger 1.14.0 → 1.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/hooks/useWinClick.js +4 -0
- package/es/index.js +10 -3
- package/lib/hooks/useWinClick.js +4 -0
- package/lib/index.js +10 -3
- package/package.json +1 -1
package/es/hooks/useWinClick.js
CHANGED
|
@@ -55,12 +55,14 @@ export default function useWinClick(open, clickToHide, targetEle, popupEle, mask
|
|
|
55
55
|
var win = getWin(popupEle);
|
|
56
56
|
win.addEventListener('mousedown', onWinMouseDown);
|
|
57
57
|
win.addEventListener('click', onWinClick);
|
|
58
|
+
win.addEventListener('contextmenu', onWinClick);
|
|
58
59
|
|
|
59
60
|
// shadow root
|
|
60
61
|
var targetShadowRoot = getShadowRoot(targetEle);
|
|
61
62
|
if (targetShadowRoot) {
|
|
62
63
|
targetShadowRoot.addEventListener('mousedown', onShadowMouseDown);
|
|
63
64
|
targetShadowRoot.addEventListener('click', onShadowClick);
|
|
65
|
+
targetShadowRoot.addEventListener('contextmenu', onShadowClick);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
// Warning if target and popup not in same root
|
|
@@ -73,9 +75,11 @@ export default function useWinClick(open, clickToHide, targetEle, popupEle, mask
|
|
|
73
75
|
return function () {
|
|
74
76
|
win.removeEventListener('mousedown', onWinMouseDown);
|
|
75
77
|
win.removeEventListener('click', onWinClick);
|
|
78
|
+
win.removeEventListener('contextmenu', onWinClick);
|
|
76
79
|
if (targetShadowRoot) {
|
|
77
80
|
targetShadowRoot.removeEventListener('mousedown', onShadowMouseDown);
|
|
78
81
|
targetShadowRoot.removeEventListener('click', onShadowClick);
|
|
82
|
+
targetShadowRoot.removeEventListener('contextmenu', onShadowClick);
|
|
79
83
|
}
|
|
80
84
|
};
|
|
81
85
|
}
|
package/es/index.js
CHANGED
|
@@ -343,7 +343,10 @@ export function generateTrigger() {
|
|
|
343
343
|
setMousePosByEvent(event);
|
|
344
344
|
});
|
|
345
345
|
onPopupMouseEnter = function onPopupMouseEnter() {
|
|
346
|
-
|
|
346
|
+
// Only trigger re-open when popup is visible
|
|
347
|
+
if (mergedOpen || inMotion) {
|
|
348
|
+
triggerOpen(true, mouseEnterDelay);
|
|
349
|
+
}
|
|
347
350
|
};
|
|
348
351
|
|
|
349
352
|
// Align Point
|
|
@@ -374,8 +377,12 @@ export function generateTrigger() {
|
|
|
374
377
|
if (showActions.has('contextMenu')) {
|
|
375
378
|
cloneProps.onContextMenu = function (event) {
|
|
376
379
|
var _originChildProps$onC2;
|
|
377
|
-
|
|
378
|
-
|
|
380
|
+
if (openRef.current && hideActions.has('contextMenu')) {
|
|
381
|
+
triggerOpen(false);
|
|
382
|
+
} else {
|
|
383
|
+
setMousePosByEvent(event);
|
|
384
|
+
triggerOpen(true);
|
|
385
|
+
}
|
|
379
386
|
event.preventDefault();
|
|
380
387
|
|
|
381
388
|
// Pass to origin
|
package/lib/hooks/useWinClick.js
CHANGED
|
@@ -63,12 +63,14 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
|
|
|
63
63
|
var win = (0, _util.getWin)(popupEle);
|
|
64
64
|
win.addEventListener('mousedown', onWinMouseDown);
|
|
65
65
|
win.addEventListener('click', onWinClick);
|
|
66
|
+
win.addEventListener('contextmenu', onWinClick);
|
|
66
67
|
|
|
67
68
|
// shadow root
|
|
68
69
|
var targetShadowRoot = (0, _shadow.getShadowRoot)(targetEle);
|
|
69
70
|
if (targetShadowRoot) {
|
|
70
71
|
targetShadowRoot.addEventListener('mousedown', onShadowMouseDown);
|
|
71
72
|
targetShadowRoot.addEventListener('click', onShadowClick);
|
|
73
|
+
targetShadowRoot.addEventListener('contextmenu', onShadowClick);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
// Warning if target and popup not in same root
|
|
@@ -81,9 +83,11 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
|
|
|
81
83
|
return function () {
|
|
82
84
|
win.removeEventListener('mousedown', onWinMouseDown);
|
|
83
85
|
win.removeEventListener('click', onWinClick);
|
|
86
|
+
win.removeEventListener('contextmenu', onWinClick);
|
|
84
87
|
if (targetShadowRoot) {
|
|
85
88
|
targetShadowRoot.removeEventListener('mousedown', onShadowMouseDown);
|
|
86
89
|
targetShadowRoot.removeEventListener('click', onShadowClick);
|
|
90
|
+
targetShadowRoot.removeEventListener('contextmenu', onShadowClick);
|
|
87
91
|
}
|
|
88
92
|
};
|
|
89
93
|
}
|
package/lib/index.js
CHANGED
|
@@ -353,7 +353,10 @@ function generateTrigger() {
|
|
|
353
353
|
setMousePosByEvent(event);
|
|
354
354
|
});
|
|
355
355
|
onPopupMouseEnter = function onPopupMouseEnter() {
|
|
356
|
-
|
|
356
|
+
// Only trigger re-open when popup is visible
|
|
357
|
+
if (mergedOpen || inMotion) {
|
|
358
|
+
triggerOpen(true, mouseEnterDelay);
|
|
359
|
+
}
|
|
357
360
|
};
|
|
358
361
|
|
|
359
362
|
// Align Point
|
|
@@ -384,8 +387,12 @@ function generateTrigger() {
|
|
|
384
387
|
if (showActions.has('contextMenu')) {
|
|
385
388
|
cloneProps.onContextMenu = function (event) {
|
|
386
389
|
var _originChildProps$onC2;
|
|
387
|
-
|
|
388
|
-
|
|
390
|
+
if (openRef.current && hideActions.has('contextMenu')) {
|
|
391
|
+
triggerOpen(false);
|
|
392
|
+
} else {
|
|
393
|
+
setMousePosByEvent(event);
|
|
394
|
+
triggerOpen(true);
|
|
395
|
+
}
|
|
389
396
|
event.preventDefault();
|
|
390
397
|
|
|
391
398
|
// Pass to origin
|