Skip to content

Commit a0e5855

Browse files
authored
Merge pull request JedWatson#1571 from interface48/aria-describedby
Adding support for aria-describedby attribute
2 parents 80943b4 + ba7dc9f commit a0e5855

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Select.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const Select = React.createClass({
4646

4747
propTypes: {
4848
addLabelText: React.PropTypes.string, // placeholder displayed when you want to add a label on a multi-value input
49+
'aria-describedby': React.PropTypes.string, // HTML ID(s) of element(s) that should be used to describe this input (for assistive tech)
4950
'aria-label': React.PropTypes.string, // Aria label (for assistive tech)
5051
'aria-labelledby': React.PropTypes.string, // HTML ID of an element that should be used as the label (for assistive tech)
5152
arrowRenderer: React.PropTypes.func, // Create drop-down caret element
@@ -853,6 +854,7 @@ const Select = React.createClass({
853854
'aria-owns': ariaOwns,
854855
'aria-haspopup': '' + isOpen,
855856
'aria-activedescendant': isOpen ? this._instancePrefix + '-option-' + focusedOptionIndex : this._instancePrefix + '-value',
857+
'aria-describedby': this.props['aria-describedby'],
856858
'aria-labelledby': this.props['aria-labelledby'],
857859
'aria-label': this.props['aria-label'],
858860
className: className,

test/Select-test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3803,6 +3803,19 @@ describe('Select', () => {
38033803
'to contain', <input role="combobox" aria-labelledby="test-label-id" />);
38043804
});
38053805

3806+
it('passes through the aria-describedby prop', () => {
3807+
3808+
instance = createControl({
3809+
options: defaultOptions,
3810+
value: 'one',
3811+
'aria-describedby': 'test-label1-id test-label2-id'
3812+
});
3813+
3814+
expect(instance,
3815+
'to contain', <input role="combobox" aria-describedby="test-label1-id test-label2-id" />);
3816+
});
3817+
3818+
38063819
it('passes through the aria-label prop', () => {
38073820

38083821
instance = createControl({

0 commit comments

Comments
 (0)