Skip to content

Commit 9d375bf

Browse files
committed
Do not trigger expand properties on nodes without children
Resolves #22.
1 parent fb1286d commit 9d375bf

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## v0.4.2 (TBA)
4+
5+
## Bug Fixes
6+
7+
* [#22]: Remove expand-like behavior on nodes without children
8+
39
## [v0.4.1](https://github.com/jakezatecky/react-checkbox-tree/compare/v0.4.0...v0.4.1) (2017-02-15)
410

511
### Deprecations

src/js/TreeNode.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,29 @@ class TreeNode extends React.Component {
5757
}
5858

5959
renderCollapseIcon() {
60-
if (this.props.rawChildren === null) {
61-
return <i className="fa" />;
62-
}
63-
6460
if (!this.props.expanded) {
6561
return <i className="fa fa-chevron-right" />;
6662
}
6763

6864
return <i className="fa fa-chevron-down" />;
6965
}
7066

67+
renderCollapseButton() {
68+
if (this.props.rawChildren === null) {
69+
return (
70+
<span className="rct-collapse">
71+
<i className="fa" />
72+
</span>
73+
);
74+
}
75+
76+
return (
77+
<button aria-label="Toggle" className="rct-collapse rct-collapse-btn" title="Toggle" onClick={this.onExpand}>
78+
{this.renderCollapseIcon()}
79+
</button>
80+
);
81+
}
82+
7183
renderCheckboxIcon() {
7284
if (this.props.checked === 0) {
7385
return <i className="fa fa-square-o" />;
@@ -107,9 +119,7 @@ class TreeNode extends React.Component {
107119
return (
108120
<li className="rct-node">
109121
<span className="rct-text">
110-
<button aria-label="Toggle" className="rct-collapse" title="Toggle" onClick={this.onExpand}>
111-
{this.renderCollapseIcon()}
112-
</button>
122+
{this.renderCollapseButton()}
113123
<label htmlFor={inputId}>
114124
<input checked={checked === 1} id={inputId} type="checkbox" onChange={this.onCheck} />
115125
<span className="rct-checkbox">

src/less/react-checkbox-tree.less

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@
5656
.rct-collapse {
5757
border: 0;
5858
background: none;
59-
cursor: pointer;
6059
padding: 0;
6160
line-height: normal;
6261
color: inherit;
6362
font-size: 12px;
6463

64+
&.rct-collapse-btn {
65+
cursor: pointer;
66+
}
67+
6568
.fa-chevron-right,
6669
.fa-chevron-down {
6770
text-align: center;

src/sass/react-checkbox-tree.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ $rct-label-hover: rgba($rct-icon-color, .1) !default;
5656
.rct-collapse {
5757
border: 0;
5858
background: none;
59-
cursor: pointer;
6059
padding: 0;
6160
line-height: normal;
6261
color: inherit;
6362
font-size: 12px;
6463

64+
&.rct-collapse-btn {
65+
cursor: pointer;
66+
}
67+
6568
.fa-chevron-right,
6669
.fa-chevron-down {
6770
text-align: center;

0 commit comments

Comments
 (0)