Skip to content

Commit e83c8d1

Browse files
committed
Merge branch 'koszti-on-click'
2 parents befe810 + 51cf427 commit e83c8d1

File tree

12 files changed

+392
-23664
lines changed

12 files changed

+392
-23664
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ All node objects **must** have a unique `value`. This value is serialized into t
9595
| `checked` | array | An array of checked node values. | `[]` |
9696
| `disabled` | bool | If true, the component will be disabled and nodes cannot be checked. | `false` |
9797
| `expandDisabled` | bool | If true, the ability to expand nodes will be disabled. | `false` |
98+
| `expandOnClick` | bool | If true, nodes will be expanded by clicking on labels. Requires a non empty `onClick` function. | `false` |
9899
| `expanded` | array | An array of expanded node values. | `[]` |
99100
| `name` | string | Optional name for the hidden `<input>` element. | `undefined` |
100101
| `nameAsArray` | bool | If true, the hidden `<input>` will encode its values as an array rather than a joined string. | `false` |
@@ -104,6 +105,7 @@ All node objects **must** have a unique `value`. This value is serialized into t
104105
| `optimisticToggle` | bool | If true, toggling a partially-checked node will select all children. If false, it will deselect. | `true` |
105106
| `showNodeIcon` | bool | If true, each node will show a parent or leaf icon. | `true` |
106107
| `onCheck` | function | onCheck handler: `function(checked) {}` | `() => {}` |
108+
| `onClick` | function | onClick handler: `function(clicked) {}`. If set, it will be called when clicked on a node label. | `() => {}` |
107109
| `onExpand` | function | onExpand handler: `function(expanded) {}` | `() => {}` |
108110

109111
#### Node Properties

examples/dist/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ <h2>Large Data Example</h2>
6464
<p>The checkbox tree is capable of supporting a large number of nodes at once.</p>
6565
<div id="large-data-example"></div>
6666

67+
<h2>Clickable Labels Example</h2>
68+
<p>
69+
By default, clicking on the node label texts toggle the checkbox value. Providing an <code>onClick</code> property the checkbox will toggle
70+
only when clicking on the checkbox and the provided function will be called when clicking on the node label text.
71+
</p>
72+
<p>
73+
When the <code>onClick</code> function is defined passing the <code>expandOnClick</code> property will expand the clicked node automatically.
74+
</p>
75+
<div id="clickable-labels-example"></div>
76+
6777
<footer class="site-footer">
6878
<span class="site-footer-owner">
6979
<a href="https://github.com/jakezatecky/react-checkbox-tree">React Checkbox Tree</a> is maintained by <a href="https://github.com/jakezatecky">jakezatecky</a>.

0 commit comments

Comments
 (0)