Skip to content

Commit 1848a5e

Browse files
committed
feat: update rc-trigger
1 parent ce07ea3 commit 1848a5e

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

components/vc-trigger/Trigger.jsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ export default {
9494
} else {
9595
popupVisible = !!props.defaultPopupVisible;
9696
}
97+
ALL_HANDLERS.forEach(h => {
98+
this[`fire${h}`] = e => {
99+
this.fireEvents(h, e);
100+
};
101+
});
97102
return {
103+
prevPopupVisible: popupVisible,
98104
sPopupVisible: popupVisible,
99105
point: null,
100106
};
@@ -103,6 +109,7 @@ export default {
103109
popupVisible(val) {
104110
if (val !== undefined) {
105111
this.sPopupVisible = val;
112+
this.prevPopupVisible = val;
106113
}
107114
},
108115
sPopupVisible(val) {
@@ -113,14 +120,6 @@ export default {
113120
});
114121
},
115122
},
116-
117-
beforeCreate() {
118-
ALL_HANDLERS.forEach(h => {
119-
this[`fire${h}`] = e => {
120-
this.fireEvents(h, e);
121-
};
122-
});
123-
},
124123
deactivated() {
125124
this.setPopupVisible(false);
126125
},
@@ -286,7 +285,15 @@ export default {
286285
}
287286
this.preClickTime = 0;
288287
this.preTouchTime = 0;
289-
if (event && event.preventDefault) {
288+
// Only prevent default when all the action is click.
289+
// https://github.com/ant-design/ant-design/issues/17043
290+
// https://github.com/ant-design/ant-design/issues/17291
291+
if (
292+
this.isClickToShow() &&
293+
(this.isClickToHide() || this.isBlurToHide()) &&
294+
event &&
295+
event.preventDefault
296+
) {
290297
event.preventDefault();
291298
}
292299
if (event && event.domEvent) {
@@ -446,19 +453,20 @@ export default {
446453
},
447454

448455
setPopupVisible(sPopupVisible, event) {
449-
const { alignPoint } = this.$props;
456+
const { alignPoint, sPopupVisible: prevPopupVisible } = this;
450457
this.clearDelayTimer();
451-
if (this.$data.sPopupVisible !== sPopupVisible) {
458+
if (prevPopupVisible !== sPopupVisible) {
452459
if (!hasProp(this, 'popupVisible')) {
453460
this.setState({
454461
sPopupVisible,
462+
prevPopupVisible,
455463
});
456464
}
457465
const listeners = getListeners(this);
458466
listeners.popupVisibleChange && listeners.popupVisibleChange(sPopupVisible);
459467
}
460468
// Always record the point position since mouseEnterDelay will delay the show
461-
if (sPopupVisible && alignPoint && event) {
469+
if (alignPoint && event) {
462470
this.setPoint(event);
463471
}
464472
},

components/vc-trigger/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// based on rc-trigger 2.6.2
1+
// based on rc-trigger 2.6.5
22
import Trigger from './Trigger';
33
export default Trigger;

0 commit comments

Comments
 (0)