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

Fix IE11 issue where focus is lost when scrolling through options #849

Merged
merged 1 commit into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ const Select = React.createClass({

handleInputBlur (event) {
if (this.refs.menu && document.activeElement.isEqualNode(this.refs.menu)) {
this.focus();
return;
}

Expand Down
25 changes: 25 additions & 0 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,31 @@ describe('Select', () => {
TestUtils.Simulate.blur(searchInputNode);
expect(onBlur, 'was called once');
});

it( 'should focus on the input when the menu is active', () => {
instance = createControl({
options: defaultOptions
});

clickArrowToOpen();
instance.refs.menu.focus();

var inputFocus = sinon.spy( instance.refs.input, "focus" );
instance.handleInputBlur();

expect( instance.refs.input.focus, 'was called once' );
} );

it( 'should not focus the input when menu is not active', () => {
instance = createControl({
options: defaultOptions
});

var inputFocus = sinon.spy( instance.refs.input, "focus" );
instance.handleInputBlur();

expect( instance.refs.input.focus, 'was not called' );
} );
});

describe('with onBlurResetsInput=true', () => {
Expand Down