Skip to content

Commit

Permalink
Merge pull request #1331 from mcls/master
Browse files Browse the repository at this point in the history
Re-added the focus() method on Select.Async
  • Loading branch information
JedWatson committed Jan 31, 2017
2 parents 9bebcd0 + ba2bd5e commit b6a0636
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ export default class Async extends Component {
return searchPromptText;
}

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

render () {
const { children, loadingPlaceholder, placeholder } = this.props;
const { isLoading, options } = this.state;
Expand Down
13 changes: 13 additions & 0 deletions test/Async-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,17 @@ describe('Async', () => {
return expect(onInputChange, 'was called times', 1);
});
});

describe('.focus()', () => {
beforeEach(() => {
createControl({});
});

it('focuses the search input', () => {
var input = asyncNode.querySelector('input');
expect(input, 'not to equal', document.activeElement);
asyncInstance.focus();
expect(input, '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 @@ -3880,4 +3880,17 @@ describe('Select', () => {
});
});
});

describe('.focus()', () => {
beforeEach(() => {
instance = createControl({});
});

it('focuses the search input', () => {
var input = ReactDOM.findDOMNode(instance.input).querySelector('input');
expect(input, 'not to equal', document.activeElement);
instance.focus();
expect(input, 'to equal', document.activeElement);
});
});
});

0 comments on commit b6a0636

Please sign in to comment.