Skip to content

Commit da685ad

Browse files
author
kappiah
committed
Merge https://github.com/JedWatson/react-select into JedWatson/react-select.git
2 parents 7a0c861 + a0e5855 commit da685ad

7 files changed

+155
-106
lines changed

README.md

+105-106
Large diffs are not rendered by default.

src/AsyncCreatable.js

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ function reduce(obj, props = {}){
1313
const AsyncCreatable = React.createClass({
1414
displayName: 'AsyncCreatableSelect',
1515

16+
focus () {
17+
this.select.focus();
18+
},
19+
1620
render () {
1721
return (
1822
<Select.Async {...this.props}>
@@ -26,6 +30,7 @@ const AsyncCreatable = React.createClass({
2630
return asyncProps.onInputChange(input);
2731
}}
2832
ref={(ref) => {
33+
this.select = ref;
2934
creatableProps.ref(ref);
3035
asyncProps.ref(ref);
3136
}}

src/Creatable.js

+4
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ const Creatable = React.createClass({
203203
}
204204
},
205205

206+
focus () {
207+
this.select.focus();
208+
},
209+
206210
render () {
207211
const {
208212
newOptionCreator,

src/Select.js

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const Select = React.createClass({
6464

6565
propTypes: {
6666
addLabelText: React.PropTypes.string, // placeholder displayed when you want to add a label on a multi-value input
67+
'aria-describedby': React.PropTypes.string, // HTML ID(s) of element(s) that should be used to describe this input (for assistive tech)
6768
'aria-label': React.PropTypes.string, // Aria label (for assistive tech)
6869
'aria-labelledby': React.PropTypes.string, // HTML ID of an element that should be used as the label (for assistive tech)
6970
arrowRenderer: React.PropTypes.func, // Create drop-down caret element
@@ -906,6 +907,7 @@ const Select = React.createClass({
906907
'aria-owns': ariaOwns,
907908
'aria-haspopup': '' + isOpen,
908909
'aria-activedescendant': isOpen ? this._instancePrefix + '-option-' + focusedOptionIndex : this._instancePrefix + '-value',
910+
'aria-describedby': this.props['aria-describedby'],
909911
'aria-labelledby': this.props['aria-labelledby'],
910912
'aria-label': this.props['aria-label'],
911913
className: className,

test/AsyncCreatable-test.js

+13
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,17 @@ describe('AsyncCreatable', () => {
5959
class: ['foo']
6060
});
6161
});
62+
63+
describe('.focus()', () => {
64+
beforeEach(() => {
65+
createControl({});
66+
TestUtils.Simulate.blur(filterInputNode);
67+
});
68+
69+
it('focuses the search input', () => {
70+
expect(filterInputNode, 'not to equal', document.activeElement);
71+
creatableInstance.focus();
72+
expect(filterInputNode, 'to equal', document.activeElement);
73+
});
74+
});
6275
});

test/Creatable-test.js

+13
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,17 @@ describe('Creatable', () => {
237237
createControl({ onInputKeyDown: event => done() });
238238
return creatableInstance.onInputKeyDown({ keyCode: 97 });
239239
});
240+
241+
describe('.focus()', () => {
242+
beforeEach(() => {
243+
createControl({});
244+
TestUtils.Simulate.blur(filterInputNode);
245+
});
246+
247+
it('focuses the search input', () => {
248+
expect(filterInputNode, 'not to equal', document.activeElement);
249+
creatableInstance.focus();
250+
expect(filterInputNode, 'to equal', document.activeElement);
251+
});
252+
});
240253
});

test/Select-test.js

+13
Original file line numberDiff line numberDiff line change
@@ -4063,6 +4063,19 @@ describe('Select', () => {
40634063
'to contain', <input role="combobox" aria-labelledby="test-label-id" />);
40644064
});
40654065

4066+
it('passes through the aria-describedby prop', () => {
4067+
4068+
instance = createControl({
4069+
options: defaultOptions,
4070+
value: 'one',
4071+
'aria-describedby': 'test-label1-id test-label2-id'
4072+
});
4073+
4074+
expect(instance,
4075+
'to contain', <input role="combobox" aria-describedby="test-label1-id test-label2-id" />);
4076+
});
4077+
4078+
40664079
it('passes through the aria-label prop', () => {
40674080

40684081
instance = createControl({

0 commit comments

Comments
 (0)