Skip to content

Commit bd3e6a6

Browse files
committed
Fix issue where the id property did not apply to the top-level CheckboxTree container
Resolves #180.
1 parent 59745da commit bd3e6a6

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
* [#127]: Change TypeScript definition of TreeNode's `label` property to `React.ReactNode` to better align with the PropType
1414
* [#145]: Fix alignment of many React properties to TypeScript typings
15+
* [#180]: Fix issue where the `id` property did not apply to the top-level CheckboxTree container
1516

1617
## [v1.5.0](https://github.com/jakezatecky/react-checkbox-tree/compare/v1.4.1...v1.5.0) (2019-01-25)
1718

src/js/CheckboxTree.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ class CheckboxTree extends React.Component {
342342
nodes,
343343
nativeCheckboxes,
344344
} = this.props;
345+
const { id } = this.state;
345346
const treeNodes = this.renderTreeNodes(nodes);
346347

347348
const className = classNames({
@@ -352,7 +353,7 @@ class CheckboxTree extends React.Component {
352353
});
353354

354355
return (
355-
<div className={className}>
356+
<div className={className} id={id}>
356357
{this.renderExpandAll()}
357358
{this.renderHiddenInput()}
358359
{treeNodes}

test/CheckboxTree.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,18 @@ describe('<CheckboxTree />', () => {
217217
});
218218

219219
describe('id', () => {
220-
it('should pass the property directly to tree nodes', () => {
220+
it('should pass the id to the top-level DOM node', () => {
221+
const wrapper = shallow(
222+
<CheckboxTree
223+
id="my-awesome-id"
224+
nodes={[{ value: 'jupiter', label: 'Jupiter' }]}
225+
/>,
226+
);
227+
228+
assert.equal('my-awesome-id', wrapper.prop('id'));
229+
});
230+
231+
it('should pass the id as a property directly to tree nodes', () => {
221232
const wrapper = shallow(
222233
<CheckboxTree
223234
id="my-awesome-id"

0 commit comments

Comments
 (0)