Skip to content

Commit 2b145a6

Browse files
committed
Add support for the aria-label attribute.
1 parent 4341dcc commit 2b145a6

12 files changed

+15
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Widget extends React.Component {
7171
render() {
7272
return (
7373
<CheckboxTree
74+
aria-label='Moons'
7475
nodes={nodes}
7576
checked={this.state.checked}
7677
expanded={this.state.expanded}
@@ -135,6 +136,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
135136
| Property | Type | Description | Default |
136137
| -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- | ----------- |
137138
| `nodes` | array | **Required**. Specifies the tree nodes and their children. | |
139+
| `aria-label` | string | a short label that describes the purpose of the tree | `null` |
138140
| `checked` | array | An array of checked node values. | `[]` |
139141
| `disabled` | bool | If true, the component will be disabled and nodes cannot be checked. | `false` |
140142
| `expandDisabled` | bool | If true, the ability to expand nodes will be disabled. | `false` |

examples/src/js/BasicExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class BasicExample extends React.Component {
114114

115115
return (
116116
<CheckboxTree
117+
aria-label='Basic Example'
117118
checked={checked}
118119
expanded={expanded}
119120
nodes={nodes}

examples/src/js/ClickableLabelsExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class ClickExample extends React.Component {
123123
return (
124124
<div className="clickable-labels">
125125
<CheckboxTree
126+
aria-label='Clickable Labels Example'
126127
checked={checked}
127128
expanded={expanded}
128129
nodes={nodes}

examples/src/js/CustomIconsExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class CustomIconsExamples extends React.Component {
6969

7070
return (
7171
<CheckboxTree
72+
aria-label='Custom Icons Example'
7273
checked={checked}
7374
expanded={expanded}
7475
nodes={nodes}

examples/src/js/DisabledExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class DisabledExample extends React.Component {
114114

115115
return (
116116
<CheckboxTree
117+
aria-label='Disabled Example'
117118
checked={checked}
118119
disabled
119120
expanded={expanded}

examples/src/js/ExpandAllExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class ExpandAllExample extends React.Component {
115115
return (
116116
<div className="expand-all-container">
117117
<CheckboxTree
118+
aria-label='Expand All/Collapse All Example'
118119
checked={checked}
119120
expanded={expanded}
120121
nodes={nodes}

examples/src/js/FilterExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class FilterExample extends React.Component {
170170
onChange={this.onFilterChange}
171171
/>
172172
<CheckboxTree
173+
aria-label='Filter Example'
173174
checked={checked}
174175
expanded={expanded}
175176
nodes={nodesFiltered}

examples/src/js/HiddenCheckboxesExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class HiddenCheckboxesExample extends React.Component {
120120

121121
return (
122122
<CheckboxTree
123+
aria-label='Hide Checkboxes Example'
123124
checked={checked}
124125
expanded={expanded}
125126
nodes={nodes}

examples/src/js/LargeDataExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class LargeDataExample extends React.Component {
5252

5353
return (
5454
<CheckboxTree
55+
aria-label='Large Data Example'
5556
checked={checked}
5657
expanded={expanded}
5758
nodes={nodes}

examples/src/js/NoCascadeExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class NoCascadeExample extends React.Component {
115115

116116
return (
117117
<CheckboxTree
118+
aria-label='No Cascading Example'
118119
checked={checked}
119120
expanded={expanded}
120121
noCascade

examples/src/js/PessimisticToggleExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class PessimisticToggleExample extends React.Component {
114114

115115
return (
116116
<CheckboxTree
117+
aria-label='Pessimistic Toggle Example'
117118
checked={checked}
118119
expanded={expanded}
119120
nodes={nodes}

src/js/CheckboxTree.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class CheckboxTree extends React.Component {
3030
static propTypes = {
3131
nodes: PropTypes.arrayOf(nodeShape).isRequired,
3232

33+
'aria-label': PropTypes.string,
3334
checked: listShape,
3435
disabled: PropTypes.bool,
3536
expandDisabled: PropTypes.bool,
@@ -53,6 +54,7 @@ class CheckboxTree extends React.Component {
5354
};
5455

5556
static defaultProps = {
57+
'aria-label': null,
5658
checked: [],
5759
disabled: false,
5860
expandDisabled: false,
@@ -447,6 +449,7 @@ class CheckboxTree extends React.Component {
447449
{this.renderExpandAll()}
448450
{this.renderHiddenInput()}
449451
<div
452+
aria-label={this.props['aria-label']}
450453
onFocus={this.onFocus}
451454
onKeyDown={this.onKeyDown}
452455
role="tree"

0 commit comments

Comments
 (0)