diff --git a/src/Async.js b/src/Async.js index e636b82b50..5de2bcef92 100644 --- a/src/Async.js +++ b/src/Async.js @@ -88,7 +88,7 @@ const Async = React.createClass({ } }, focus () { - this.refs.select.focus(); + this.select.focus(); }, resetState () { this._currentRequestId = -1; @@ -153,7 +153,7 @@ const Async = React.createClass({ return ( component input = input.getInput(); @@ -365,7 +365,7 @@ const Select = React.createClass({ handleInputBlur (event) { // The check for menu.contains(activeElement) is necessary to prevent IE11's scrollbar from closing the menu in certain contexts. - if (this.refs.menu && (this.refs.menu === document.activeElement || this.refs.menu.contains(document.activeElement))) { + if (this.menu && (this.menu === document.activeElement || this.menu.contains(document.activeElement))) { this.focus(); return; } @@ -763,7 +763,7 @@ const Select = React.createClass({ onBlur: this.handleInputBlur, onChange: this.handleInputChange, onFocus: this.handleInputFocus, - ref: 'input', + ref: ref => this.input = ref, required: this.state.required, value: this.state.inputValue }); @@ -781,7 +781,7 @@ const Select = React.createClass({ tabIndex={this.props.tabIndex || 0} onBlur={this.handleInputBlur} onFocus={this.handleInputFocus} - ref="input" + ref={ref => this.input = ref} aria-readonly={'' + !!this.props.disabled} style={{ border: 0, width: 1, display:'inline-block' }}/> ); @@ -926,7 +926,7 @@ const Select = React.createClass({ return ( this.value = ref} name={this.props.name} value={value} disabled={this.props.disabled} /> @@ -967,8 +967,8 @@ const Select = React.createClass({ } return ( -
-
this.menuContainer = ref} className="Select-menu-outer" style={this.props.menuContainerStyle}> +
this.menu = ref} role="listbox" className="Select-menu" id={this._instancePrefix + '-list'} style={this.props.menuStyle} onScroll={this.handleMenuScroll} onMouseDown={this.handleMouseDownOnMenu}> @@ -1018,11 +1018,11 @@ const Select = React.createClass({ } return ( -
this.wrapper = ref} className={className} style={this.props.wrapperStyle}> {this.renderHiddenField(valueArray)} -
this.control = ref} className="Select-control" style={this.props.style} onKeyDown={this.handleKeyDown} diff --git a/test/Select-test.js b/test/Select-test.js index 748541e32a..bc847ba3ce 100644 --- a/test/Select-test.js +++ b/test/Select-test.js @@ -46,12 +46,12 @@ class PropsWrapper extends React.Component { } getChild() { - return this.refs.child; + return this.child; } render() { var Component = this.props.childComponent; // eslint-disable-line react/prop-types - return ; + return this.child = ref} />; } } @@ -119,7 +119,7 @@ describe('Select', () => { var findAndFocusInputControl = () => { // Focus on the input, such that mouse events are accepted - var searchInstance = ReactDOM.findDOMNode(instance.refs.input); + var searchInstance = ReactDOM.findDOMNode(instance.input); searchInputNode = null; if (searchInstance) { searchInputNode = searchInstance.querySelector('input'); @@ -2233,7 +2233,7 @@ describe('Select', () => { it('adds the className on to the auto-size input', () => { - expect(ReactDOM.findDOMNode(instance.refs.input), + expect(ReactDOM.findDOMNode(instance.input), 'to have attributes', { class: ['extra-class-name', 'Select-input'] }); @@ -2487,12 +2487,12 @@ describe('Select', () => { }); clickArrowToOpen(); - instance.refs.menu.focus(); + instance.menu.focus(); - var inputFocus = sinon.spy( instance.refs.input, 'focus' ); + var inputFocus = sinon.spy( instance.input, 'focus' ); instance.handleInputBlur(); - expect( instance.refs.input.focus, 'was called once' ); + expect( instance.input.focus, 'was called once' ); } ); it( 'should not focus the input when menu is not active', () => { @@ -2500,10 +2500,10 @@ describe('Select', () => { options: defaultOptions }); - var inputFocus = sinon.spy( instance.refs.input, 'focus' ); + var inputFocus = sinon.spy( instance.input, 'focus' ); instance.handleInputBlur(); - expect( instance.refs.input.focus, 'was not called' ); + expect( instance.input.focus, 'was not called' ); } ); }); @@ -3236,7 +3236,7 @@ describe('Select', () => { }); it('creates a plain input instead of an autosizable input', () => { - const inputNode = ReactDOM.findDOMNode(instance.refs.input); + const inputNode = ReactDOM.findDOMNode(instance.input); expect(inputNode.tagName, 'to equal', 'INPUT'); }); });