行的onclick和onDoubleclick事件冲突

This commit is contained in:
jonyshi 2018-05-02 15:35:06 +08:00
parent fbaa78026c
commit d11bbbd420
1 changed files with 16 additions and 1 deletions

View File

@ -43,6 +43,7 @@ const defaultProps = {
class TableRow extends Component{ class TableRow extends Component{
constructor(props){ constructor(props){
super(props); super(props);
this._timeout = null;
this.state = { this.state = {
hovered: false, hovered: false,
}; };
@ -86,11 +87,14 @@ class TableRow extends Component{
if (expandable && expandRowByClick) { if (expandable && expandRowByClick) {
onExpand(!expanded, record, index,event); onExpand(!expanded, record, index,event);
} }
onRowClick(record, index, event); this.set((e)=> {
onRowClick(record, index, event);
});
} }
onRowDoubleClick(event) { onRowDoubleClick(event) {
const { record, index, onRowDoubleClick } = this.props; const { record, index, onRowDoubleClick } = this.props;
this.clear();
onRowDoubleClick(record, index, event); onRowDoubleClick(record, index, event);
} }
@ -104,6 +108,17 @@ class TableRow extends Component{
onHover(false, hoverKey); onHover(false, hoverKey);
} }
set =(fn)=> {
this.clear();
this._timeout = window.setTimeout(fn, 300);
}
clear =(event)=> {
if (this._timeout) {
window.clearTimeout(this._timeout);
}
}
render() { render() {
const { const {
clsPrefix, columns, record, height, visible, index, clsPrefix, columns, record, height, visible, index,