fix: fix event memory leak

pull/22207/head
zengk 2022-10-23 15:48:56 +08:00
parent 5d7374bf16
commit a9918f276c
1 changed files with 13 additions and 14 deletions

View File

@ -113,18 +113,7 @@ export default {
this.$el.setAttribute('tabindex', this.tabindex); this.$el.setAttribute('tabindex', this.tabindex);
on(this.referenceElm, 'mouseenter', this.show); on(this.referenceElm, 'mouseenter', this.show);
on(this.referenceElm, 'mouseleave', this.hide); on(this.referenceElm, 'mouseleave', this.hide);
on(this.referenceElm, 'focus', () => { on(this.referenceElm, 'focus', this.handleFocus);
if (!this.$slots.default || !this.$slots.default.length) {
this.handleFocus();
return;
}
const instance = this.$slots.default[0].componentInstance;
if (instance && instance.focus) {
instance.focus();
} else {
this.handleFocus();
}
});
on(this.referenceElm, 'blur', this.handleBlur); on(this.referenceElm, 'blur', this.handleBlur);
on(this.referenceElm, 'click', this.removeFocusing); on(this.referenceElm, 'click', this.removeFocusing);
} }
@ -157,8 +146,18 @@ export default {
this.debounceClose(); this.debounceClose();
}, },
handleFocus() { handleFocus() {
this.focusing = true; if (!this.$slots.default || !this.$slots.default.length) {
this.show(); this.focusing = true;
this.show();
return;
}
const instance = this.$slots.default[0].componentInstance;
if (instance && instance.focus) {
instance.focus();
} else {
this.focusing = true;
this.show();
}
}, },
handleBlur() { handleBlur() {
this.focusing = false; this.focusing = false;