Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master from JedWatson/react-select (again) #62

Merged
merged 11 commits into from
Apr 22, 2017
211 changes: 105 additions & 106 deletions README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/AsyncCreatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function reduce(obj, props = {}){
const AsyncCreatable = React.createClass({
displayName: 'AsyncCreatableSelect',

focus () {
this.select.focus();
},

render () {
return (
<Select.Async {...this.props}>
Expand All @@ -26,6 +30,7 @@ const AsyncCreatable = React.createClass({
return asyncProps.onInputChange(input);
}}
ref={(ref) => {
this.select = ref;
creatableProps.ref(ref);
asyncProps.ref(ref);
}}
Expand Down
4 changes: 4 additions & 0 deletions src/Creatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ const Creatable = React.createClass({
}
},

focus () {
this.select.focus();
},

render () {
const {
newOptionCreator,
Expand Down
2 changes: 2 additions & 0 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const Select = React.createClass({

propTypes: {
addLabelText: React.PropTypes.string, // placeholder displayed when you want to add a label on a multi-value input
'aria-describedby': React.PropTypes.string, // HTML ID(s) of element(s) that should be used to describe this input (for assistive tech)
'aria-label': React.PropTypes.string, // Aria label (for assistive tech)
'aria-labelledby': React.PropTypes.string, // HTML ID of an element that should be used as the label (for assistive tech)
arrowRenderer: React.PropTypes.func, // Create drop-down caret element
Expand Down Expand Up @@ -906,6 +907,7 @@ const Select = React.createClass({
'aria-owns': ariaOwns,
'aria-haspopup': '' + isOpen,
'aria-activedescendant': isOpen ? this._instancePrefix + '-option-' + focusedOptionIndex : this._instancePrefix + '-value',
'aria-describedby': this.props['aria-describedby'],
'aria-labelledby': this.props['aria-labelledby'],
'aria-label': this.props['aria-label'],
className: className,
Expand Down
13 changes: 13 additions & 0 deletions test/AsyncCreatable-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,17 @@ describe('AsyncCreatable', () => {
class: ['foo']
});
});

describe('.focus()', () => {
beforeEach(() => {
createControl({});
TestUtils.Simulate.blur(filterInputNode);
});

it('focuses the search input', () => {
expect(filterInputNode, 'not to equal', document.activeElement);
creatableInstance.focus();
expect(filterInputNode, 'to equal', document.activeElement);
});
});
});
13 changes: 13 additions & 0 deletions test/Creatable-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,17 @@ describe('Creatable', () => {
createControl({ onInputKeyDown: event => done() });
return creatableInstance.onInputKeyDown({ keyCode: 97 });
});

describe('.focus()', () => {
beforeEach(() => {
createControl({});
TestUtils.Simulate.blur(filterInputNode);
});

it('focuses the search input', () => {
expect(filterInputNode, 'not to equal', document.activeElement);
creatableInstance.focus();
expect(filterInputNode, 'to equal', document.activeElement);
});
});
});
13 changes: 13 additions & 0 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4063,6 +4063,19 @@ describe('Select', () => {
'to contain', <input role="combobox" aria-labelledby="test-label-id" />);
});

it('passes through the aria-describedby prop', () => {

instance = createControl({
options: defaultOptions,
value: 'one',
'aria-describedby': 'test-label1-id test-label2-id'
});

expect(instance,
'to contain', <input role="combobox" aria-describedby="test-label1-id test-label2-id" />);
});


it('passes through the aria-label prop', () => {

instance = createControl({
Expand Down