Skip to content

Commit 14d0f38

Browse files
committed
Fix render errors for all numeric value types (not just integers)
Resolves #81.
1 parent a862af5 commit 14d0f38

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
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+
## v1.2.3 (TBA)
4+
5+
### Bug Fixes
6+
7+
* [#81]: Fix render errors for all numeric value types
8+
39
## [v1.2.2](https://github.com/jakezatecky/react-checkbox-tree/compare/v1.2.1...v1.2.2) (2018-05-24)
410

511
### Bug Fixes

src/js/TreeNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class TreeNode extends React.Component {
195195
} = this.props;
196196

197197
const clickable = onClick.toString() !== TreeNode.defaultProps.onClick.toString();
198-
const inputId = `${treeId}-${Number.isInteger(value) ? value : value.split(' ').join('_')}`;
198+
const inputId = `${treeId}-${String(value).split(' ').join('_')}`;
199199

200200
const render = [(
201201
<label key={0} htmlFor={inputId}>

test/TreeNode.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ describe('<TreeNode />', () => {
4545
assert.equal('planets-0', wrapper.find('label').prop('htmlFor'));
4646
assert.equal('planets-0', wrapper.find('label NativeCheckbox').prop('id'));
4747
});
48+
49+
it('should render a label associated with a checkbox given float value', () => {
50+
const wrapper = shallow(
51+
<TreeNode {...baseProps} treeId="planets" value={0.25} />,
52+
);
53+
54+
assert.equal('planets-0.25', wrapper.find('label').prop('htmlFor'));
55+
assert.equal('planets-0.25', wrapper.find('label NativeCheckbox').prop('id'));
56+
});
4857
});
4958

5059
describe('checked', () => {

0 commit comments

Comments
 (0)