fix: 优化onBodyMouseLeave调用

This commit is contained in:
malong 2020-11-19 18:51:02 +08:00
parent 478f9853ec
commit 3b1ffecacd
1 changed files with 20 additions and 7 deletions

View File

@ -1286,11 +1286,23 @@ class Table extends Component {
isRowExpanded(record, index) { isRowExpanded(record, index) {
return typeof this.findExpandedRow(record, index) !== 'undefined'; return typeof this.findExpandedRow(record, index) !== 'undefined';
} }
clearBodyMouseLeaveTimer = () => {
if (this.bodyMouseLeaveTimmer) {
clearTimeout(this.bodyMouseLeaveTimmer)
this.bodyMouseLeaveTimmer = null
}
}
onBodyMouseLeave(e){ onBodyMouseLeave(e){
this.hideHoverDom(e); this.hideHoverDom(e);
const {onBodyMouseLeave} = this.props; const {onBodyMouseLeave} = this.props;
if(onBodyMouseLeave) { if (typeof onBodyMouseLeave === 'function') {
onBodyMouseLeave() this.clearBodyMouseLeaveTimer();
//因为鼠标移动到 hoverContent 中也会触发 onBodyMouseLeave这是错误的
//所以讲 onBodyMouseLeave 回调的调用放入 setTimeout中
// 当触发 hoverContent 的 onRowHoverMouseEnter 回调时,清除此定时器
this.bodyMouseLeaveTimmer = setTimeout(onBodyMouseLeave, 0)
} }
} }
@ -1418,6 +1430,7 @@ class Table extends Component {
currentHoverKey: this.currentHoverKey, currentHoverKey: this.currentHoverKey,
}); });
this.hoverDom.style.display = 'block'; this.hoverDom.style.display = 'block';
this.clearBodyMouseLeaveTimer();
} }
onRowHoverMouseLeave = () =>{ onRowHoverMouseLeave = () =>{