fix: stop propatation when cliking or checking a node

This commit is contained in:
gx 2021-03-22 10:47:57 +08:00
parent 35d394215d
commit 09b9d18e58
5 changed files with 6546 additions and 3270 deletions

File diff suppressed because one or more lines are too long

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

9799
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -177,6 +177,12 @@ class TreeNode extends React.Component {
}
onStopPropagation = event => {
if (event) {
event.stopPropagation()
}
}
renderSwitcher(props, expandedState) {
let stateIcon;
const prefixCls = props.prefixCls;
@ -206,7 +212,7 @@ class TreeNode extends React.Component {
switcherCls[`${prefixCls}-switcher-disabled`] = true;
return <span className={classNames(switcherCls)} style={props.switcherStyle}>{stateIcon}</span>;
}
return <span className={classNames(switcherCls)} style={props.switcherStyle} onClick={this.onExpand}>{stateIcon}</span>;
return <span className={classNames(switcherCls)} style={props.switcherStyle} onMouseDown={this.onStopPropagation} onClick={this.onExpand}>{stateIcon}</span>;
}
renderCheckbox(props) {
@ -228,9 +234,10 @@ class TreeNode extends React.Component {
return <span className={classNames(checkboxCls)}>{customEle}</span>;
}
return (
<span
<span
className={classNames(checkboxCls) }
onClick={this.onCheck}
onMouseDown={this.onStopPropagation}
>{customEle}</span>);
}