Skip to content

Commit

Permalink
⭐ add support for focus() on Async which passes through to Select
Browse files Browse the repository at this point in the history
  • Loading branch information
Bee Wilkerson committed Oct 23, 2016
1 parent b1c4cc0 commit 91c5041
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
9 changes: 8 additions & 1 deletion dist/react-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ var Async = (function (_Component) {
onInputChange: this._onInputChange
}));
}
}, {
key: 'focus',
value: function focus() {
if (this.refs.select !== null) {
this.refs.select.focus();
}
}
}]);

return Async;
Expand All @@ -200,7 +207,7 @@ Async.propTypes = propTypes;
Async.defaultProps = defaultProps;

function defaultChildren(props) {
return _react2['default'].createElement(_Select2['default'], props);
return _react2['default'].createElement(_Select2['default'], _extends({}, props, { ref: 'select' }));
};
module.exports = exports['default'];

Expand Down
4 changes: 2 additions & 2 deletions dist/react-select.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion examples/dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ var Async = (function (_Component) {
onInputChange: this._onInputChange
}));
}
}, {
key: 'focus',
value: function focus() {
if (this.refs.select !== null) {
this.refs.select.focus();
}
}
}]);

return Async;
Expand All @@ -199,7 +206,7 @@ Async.propTypes = propTypes;
Async.defaultProps = defaultProps;

function defaultChildren(props) {
return _react2['default'].createElement(_Select2['default'], props);
return _react2['default'].createElement(_Select2['default'], _extends({}, props, { ref: 'select' }));
};
module.exports = exports['default'];

Expand Down
9 changes: 8 additions & 1 deletion examples/dist/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ var Async = (function (_Component) {
onInputChange: this._onInputChange
}));
}
}, {
key: 'focus',
value: function focus() {
if (this.refs.select !== null) {
this.refs.select.focus();
}
}
}]);

return Async;
Expand All @@ -200,7 +207,7 @@ Async.propTypes = propTypes;
Async.defaultProps = defaultProps;

function defaultChildren(props) {
return _react2['default'].createElement(_Select2['default'], props);
return _react2['default'].createElement(_Select2['default'], _extends({}, props, { ref: 'select' }));
};
module.exports = exports['default'];

Expand Down
9 changes: 8 additions & 1 deletion lib/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ var Async = (function (_Component) {
onInputChange: this._onInputChange
}));
}
}, {
key: 'focus',
value: function focus() {
if (this.refs.select !== null) {
this.refs.select.focus();
}
}
}]);

return Async;
Expand All @@ -198,6 +205,6 @@ Async.propTypes = propTypes;
Async.defaultProps = defaultProps;

function defaultChildren(props) {
return _react2['default'].createElement(_Select2['default'], props);
return _react2['default'].createElement(_Select2['default'], _extends({}, props, { ref: 'select' }));
};
module.exports = exports['default'];
9 changes: 8 additions & 1 deletion src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,20 @@ export default class Async extends Component {
onInputChange: this._onInputChange
});
}

focus () {
if(this.refs.select !== null) {
this.refs.select.focus();
}
}
}


Async.propTypes = propTypes;
Async.defaultProps = defaultProps;

function defaultChildren (props) {
return (
<Select {...props} />
<Select {...props} ref="select"/>
);
};

0 comments on commit 91c5041

Please sign in to comment.