Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Toggle node by clicking on label. #644

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tree-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class TreeNode extends PureComponent {
showPartiallySelected={showPartiallySelected}
readOnly={readOnly}
clientId={clientId}
onNodeToggle={onNodeToggle}
/>
<Actions actions={actions} onAction={onAction} id={_id} readOnly={readOnly} />
</li>
Expand Down
8 changes: 7 additions & 1 deletion src/tree-node/node-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class NodeLabel extends PureComponent {
e.nativeEvent.stopImmediatePropagation()
}

onToggle = e => {
e.stopPropagation()
e.nativeEvent.stopImmediatePropagation()
this.props.onNodeToggle(this.props.id)
}

render() {
const { mode, title, label, id, partial, checked } = this.props
const { value, disabled, showPartiallySelected, readOnly, clientId } = this.props
Expand All @@ -53,7 +59,7 @@ class NodeLabel extends PureComponent {
const className = ['checkbox-item', mode === 'simpleSelect' && 'simple-select'].filter(Boolean).join(' ')

return (
<label title={title || label} htmlFor={id}>
<label title={title || label} htmlFor={id} onClick={this.onToggle}>
{mode === 'radioSelect' ? (
<RadioButton name={clientId} className="radio-item" onChange={this.handleCheckboxChange} {...sharedProps} />
) : (
Expand Down
Loading