aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Header.jsx
diff options
context:
space:
mode:
author偏右 <afc163@gmail.com>2017-10-22 16:38:04 +0800
committerGitHub <noreply@github.com>2017-10-22 16:38:04 +0800
commitf0ac29c61df164ab3e867ef86137faa13d85a87f (patch)
tree6b1baa2373001870fa00310da36d46b21e8a43c8 /src/Header.jsx
parentcc2dca8a2bb0bf3b820903043be2586fb413c458 (diff)
parent8a116e355bfabda48537be06d21cf01fdceaa8b7 (diff)
downloadtime-picker-f0ac29c61df164ab3e867ef86137faa13d85a87f.tar.gz
time-picker-f0ac29c61df164ab3e867ef86137faa13d85a87f.tar.zst
time-picker-f0ac29c61df164ab3e867ef86137faa13d85a87f.zip
Merge branch 'master' into picker-step
Diffstat (limited to 'src/Header.jsx')
-rw-r--r--src/Header.jsx12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Header.jsx b/src/Header.jsx
index f6dd241..1520d25 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 onKeyDown: PropTypes.func, 26 onKeyDown: PropTypes.func,
26 }; 27 };
27 28
@@ -34,6 +35,17 @@ class Header extends Component {
34 }; 35 };
35 } 36 }
36 37
38 componentDidMount() {
39 if (this.props.focusOnOpen) {
40 // Wait one frame for the panel to be positioned before focusing
41 const requestAnimationFrame = (window.requestAnimationFrame || window.setTimeout);
42 requestAnimationFrame(() => {
43 this.refs.input.focus();
44 this.refs.input.select();
45 });
46 }
47 }
48
37 componentWillReceiveProps(nextProps) { 49 componentWillReceiveProps(nextProps) {
38 const { value, format } = nextProps; 50 const { value, format } = nextProps;
39 this.setState({ 51 this.setState({