aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
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
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')
-rw-r--r--src/Header.jsx12
-rw-r--r--src/Panel.jsx6
-rw-r--r--src/TimePicker.jsx5
3 files changed, 20 insertions, 3 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({
diff --git a/src/Panel.jsx b/src/Panel.jsx
index 4e09b57..a1b7c77 100644
--- a/src/Panel.jsx
+++ b/src/Panel.jsx
@@ -43,6 +43,7 @@ class Panel extends Component {
43 minuteStep: PropTypes.number, 43 minuteStep: PropTypes.number,
44 secondStep: PropTypes.number, 44 secondStep: PropTypes.number,
45 addon: PropTypes.func, 45 addon: PropTypes.func,
46 focusOnOpen: PropTypes.bool,
46 onKeyDown: PropTypes.func, 47 onKeyDown: PropTypes.func,
47 }; 48 };
48 49
@@ -94,8 +95,8 @@ class Panel extends Component {
94 const { 95 const {
95 prefixCls, className, placeholder, disabledHours, disabledMinutes, 96 prefixCls, className, placeholder, disabledHours, disabledMinutes,
96 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, 97 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond,
97 format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, onKeyDown, 98 format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear,
98 hourStep, minuteStep, secondStep, 99 focusOnOpen, onKeyDown, hourStep, minuteStep, secondStep,
99 } = this.props; 100 } = this.props;
100 const { 101 const {
101 value, currentSelectPanel, 102 value, currentSelectPanel,
@@ -134,6 +135,7 @@ class Panel extends Component {
134 onChange={this.onChange} 135 onChange={this.onChange}
135 onClear={onClear} 136 onClear={onClear}
136 allowEmpty={allowEmpty} 137 allowEmpty={allowEmpty}
138 focusOnOpen={focusOnOpen}
137 onKeyDown={onKeyDown} 139 onKeyDown={onKeyDown}
138 /> 140 />
139 <Combobox 141 <Combobox
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index 5f2239a..c7ff80a 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -51,6 +51,7 @@ export default class Picker extends Component {
51 hourStep: PropTypes.number, 51 hourStep: PropTypes.number,
52 minuteStep: PropTypes.number, 52 minuteStep: PropTypes.number,
53 secondStep: PropTypes.number, 53 secondStep: PropTypes.number,
54 focusOnOpen: PropTypes.bool,
54 onKeyDown: PropTypes.func, 55 onKeyDown: PropTypes.func,
55 }; 56 };
56 57
@@ -79,6 +80,7 @@ export default class Picker extends Component {
79 onBlur: noop, 80 onBlur: noop,
80 addon: noop, 81 addon: noop,
81 use12Hours: false, 82 use12Hours: false,
83 focusOnOpen: false,
82 onKeyDown: noop, 84 onKeyDown: noop,
83 }; 85 };
84 86
@@ -166,7 +168,7 @@ export default class Picker extends Component {
166 prefixCls, placeholder, disabledHours, 168 prefixCls, placeholder, disabledHours,
167 disabledMinutes, disabledSeconds, hideDisabledOptions, 169 disabledMinutes, disabledSeconds, hideDisabledOptions,
168 allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, 170 allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
169 addon, use12Hours, onKeyDown, hourStep, minuteStep, secondStep, 171 addon, use12Hours, focusOnOpen, onKeyDown, hourStep, minuteStep, secondStep,
170 } = this.props; 172 } = this.props;
171 return ( 173 return (
172 <Panel 174 <Panel
@@ -193,6 +195,7 @@ export default class Picker extends Component {
193 minuteStep={minuteStep} 195 minuteStep={minuteStep}
194 secondStep={secondStep} 196 secondStep={secondStep}
195 addon={addon} 197 addon={addon}
198 focusOnOpen={focusOnOpen}
196 onKeyDown={onKeyDown} 199 onKeyDown={onKeyDown}
197 /> 200 />
198 ); 201 );