diff --git a/CHANGELOG.md b/CHANGELOG.md index 89e18d6c..cbc1635f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * [#127]: Change TypeScript definition of TreeNode's `label` property to `React.ReactNode` to better align with the PropType * [#145]: Fix alignment of many React properties to TypeScript typings +* [#180]: Fix issue where the `id` property did not apply to the top-level CheckboxTree container ## [v1.5.0](https://github.com/jakezatecky/react-checkbox-tree/compare/v1.4.1...v1.5.0) (2019-01-25) diff --git a/src/js/CheckboxTree.js b/src/js/CheckboxTree.js index 90b5228d..2e2a99ae 100644 --- a/src/js/CheckboxTree.js +++ b/src/js/CheckboxTree.js @@ -342,6 +342,7 @@ class CheckboxTree extends React.Component { nodes, nativeCheckboxes, } = this.props; + const { id } = this.state; const treeNodes = this.renderTreeNodes(nodes); const className = classNames({ @@ -352,7 +353,7 @@ class CheckboxTree extends React.Component { }); return ( -
+
{this.renderExpandAll()} {this.renderHiddenInput()} {treeNodes} diff --git a/test/CheckboxTree.js b/test/CheckboxTree.js index 8e9621e1..4c7f3c26 100644 --- a/test/CheckboxTree.js +++ b/test/CheckboxTree.js @@ -217,7 +217,18 @@ describe('', () => { }); describe('id', () => { - it('should pass the property directly to tree nodes', () => { + it('should pass the id to the top-level DOM node', () => { + const wrapper = shallow( + , + ); + + assert.equal('my-awesome-id', wrapper.prop('id')); + }); + + it('should pass the id as a property directly to tree nodes', () => { const wrapper = shallow(