Optimize Tree contextMenu

This commit is contained in:
梁灏 2020-09-02 10:58:26 +08:00
parent baa83cac60
commit e3d2e05598

View file

@ -205,6 +205,8 @@
this.$emit('on-check-change', this.getCheckedNodes(), node); this.$emit('on-check-change', this.getCheckedNodes(), node);
}, },
handleContextmenu ({ data, event }) { handleContextmenu ({ data, event }) {
if (this.contextMenuVisible) this.handleClickContextMenuOutside();
this.$nextTick(() => {
const $TreeWrap = this.$refs.treeWrap; const $TreeWrap = this.$refs.treeWrap;
const TreeBounding = $TreeWrap.getBoundingClientRect(); const TreeBounding = $TreeWrap.getBoundingClientRect();
const position = { const position = {
@ -214,6 +216,7 @@
this.contextMenuStyles = position; this.contextMenuStyles = position;
this.contextMenuVisible = true; this.contextMenuVisible = true;
this.$emit('on-contextmenu', data, event, position); this.$emit('on-contextmenu', data, event, position);
});
}, },
handleClickContextMenuOutside () { handleClickContextMenuOutside () {
this.contextMenuVisible = false; this.contextMenuVisible = false;