fix(DropdownMenu): should't close when custom container and get clicked (#5047)

This commit is contained in:
neverland 2019-11-19 20:36:28 +08:00 committed by GitHub
parent 73847ec83e
commit dbd0951b30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,14 @@ export default createComponent({
} }
}, },
beforeCreate() {
const createEmitter = eventName => () => this.$emit(eventName);
this.onOpen = createEmitter('open');
this.onClose = createEmitter('close');
this.onOpened = createEmitter('opened');
},
methods: { methods: {
toggle(show = !this.showPopup, options = {}) { toggle(show = !this.showPopup, options = {}) {
if (show === this.showPopup) { if (show === this.showPopup) {
@ -53,17 +61,15 @@ export default createComponent({
this.parent.updateOffset(); this.parent.updateOffset();
this.showWrapper = true; this.showWrapper = true;
} }
},
onClickWrapper(event) {
if (this.getContainer) {
event.stopPropagation();
}
} }
}, },
beforeCreate() {
const createEmitter = eventName => () => this.$emit(eventName);
this.onOpen = createEmitter('open');
this.onClose = createEmitter('close');
this.onOpened = createEmitter('opened');
},
render() { render() {
const { const {
zIndex, zIndex,
@ -113,6 +119,7 @@ export default createComponent({
ref="wrapper" ref="wrapper"
style={style} style={style}
class={bem([direction])} class={bem([direction])}
onClick={this.onClickWrapper}
> >
<Popup <Popup
vModel={this.showPopup} vModel={this.showPopup}