fix(DropdownMenu): incorrect menu position when scroll (#5313)

This commit is contained in:
neverland
2019-12-19 16:51:41 +08:00
committed by GitHub
parent df6de0c7e4
commit 329a5cd0c3
3 changed files with 27 additions and 3 deletions
+19 -2
View File
@@ -1,9 +1,10 @@
import { createNamespace } from '../utils';
import { PortalMixin } from '../mixins/portal';
import { ChildrenMixin } from '../mixins/relation';
import { on, off } from '../utils/dom/event';
import Cell from '../cell';
import Icon from '../icon';
import Popup from '../popup';
import { PortalMixin } from '../mixins/portal';
import { ChildrenMixin } from '../mixins/relation';
const [createComponent, bem] = createNamespace('dropdown-item');
@@ -40,6 +41,12 @@ export default createComponent({
}
},
watch: {
showPopup(val) {
this.bindScroll(val);
}
},
beforeCreate() {
const createEmitter = eventName => () => this.$emit(eventName);
@@ -63,6 +70,16 @@ export default createComponent({
}
},
bindScroll(bind) {
const { scroller } = this.parent;
const action = bind ? on : off;
action(scroller, 'scroll', this.onScroll, true);
},
onScroll() {
this.parent.updateOffset();
},
onClickWrapper(event) {
// prevent being identified as clicking outside and closed when use get-contaienr
if (this.getContainer) {