fix: change stopPropatation event

This commit is contained in:
gx 2021-03-22 12:27:07 +08:00
parent 71ee2bc07a
commit c08be8d6a8
3 changed files with 19 additions and 16 deletions

19
dist/demo.js vendored
View File

@ -41295,13 +41295,6 @@
var _this2 = _possibleConstructorReturn(this, _React$Component.call(this, props));
_this2.onStopPropagation = function (event) {
console.log('caili');
if (event) {
event.stopPropagation();
}
};
_this2.getNodeChildren = function () {
var children = _this2.props.children;
@ -41461,6 +41454,14 @@
}
};
TreeNode.prototype.onSwitcherMouseDown = function onSwitcherMouseDown(e) {
e.preventDefault();
};
TreeNode.prototype.onCheckboxMouseDown = function onCheckboxMouseDown(e) {
e.preventDefault();
};
TreeNode.prototype.renderSwitcher = function renderSwitcher(props, expandedState) {
var stateIcon = void 0;
var prefixCls = props.prefixCls;
@ -41494,7 +41495,7 @@
}
return _react2['default'].createElement(
'span',
{ className: (0, _classnames2['default'])(switcherCls), style: props.switcherStyle, onMouseDown: this.onStopPropagation, onClick: this.onExpand },
{ className: (0, _classnames2['default'])(switcherCls), style: props.switcherStyle, onMouseDown: this.onSwitcherMouseDown, onClick: this.onExpand },
stateIcon
);
};
@ -41524,7 +41525,7 @@
{
className: (0, _classnames2['default'])(checkboxCls),
onClick: this.onCheck,
onMouseDown: this.onStopPropagation
onMouseDown: this.onCheckboxMouseDown
},
customEle
);

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -177,10 +177,12 @@ class TreeNode extends React.Component {
}
onStopPropagation = event => {
if (event) {
event.stopPropagation()
}
onSwitcherMouseDown(e) {
e.preventDefault();
}
onCheckboxMouseDown (e) {
e.preventDefault();
}
renderSwitcher(props, expandedState) {
@ -212,7 +214,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} onMouseDown={this.onStopPropagation} onClick={this.onExpand}>{stateIcon}</span>;
return <span className={classNames(switcherCls)} style={props.switcherStyle} onMouseDown={this.onSwitcherMouseDown} onClick={this.onExpand}>{stateIcon}</span>;
}
renderCheckbox(props) {
@ -237,7 +239,7 @@ class TreeNode extends React.Component {
<span
className={classNames(checkboxCls) }
onClick={this.onCheck}
onMouseDown={this.onStopPropagation}
onMouseDown={this.onCheckboxMouseDown}
>{customEle}</span>);
}