diff options
Diffstat (limited to 'src/Header.jsx')
-rw-r--r-- | src/Header.jsx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Header.jsx b/src/Header.jsx index 91e8549..9e80a9c 100644 --- a/src/Header.jsx +++ b/src/Header.jsx | |||
@@ -22,6 +22,7 @@ class Header extends Component { | |||
22 | allowEmpty: PropTypes.bool, | 22 | allowEmpty: PropTypes.bool, |
23 | defaultOpenValue: PropTypes.object, | 23 | defaultOpenValue: PropTypes.object, |
24 | currentSelectPanel: PropTypes.string, | 24 | currentSelectPanel: PropTypes.string, |
25 | focusOnOpen: PropTypes.bool, | ||
25 | }; | 26 | }; |
26 | 27 | ||
27 | constructor(props) { | 28 | constructor(props) { |
@@ -33,6 +34,14 @@ class Header extends Component { | |||
33 | }; | 34 | }; |
34 | } | 35 | } |
35 | 36 | ||
37 | componentDidMount() { | ||
38 | if (this.props.focusOnOpen) { | ||
39 | // Wait one frame for the panel to be positioned before focusing | ||
40 | const requestAnimationFrame = (window.requestAnimationFrame || window.setTimeout); | ||
41 | requestAnimationFrame(() => this.refs.input.focus()); | ||
42 | } | ||
43 | } | ||
44 | |||
36 | componentWillReceiveProps(nextProps) { | 45 | componentWillReceiveProps(nextProps) { |
37 | const { value, format } = nextProps; | 46 | const { value, format } = nextProps; |
38 | this.setState({ | 47 | this.setState({ |