diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Header.jsx | 12 | ||||
-rw-r--r-- | src/Panel.jsx | 4 | ||||
-rw-r--r-- | src/TimePicker.jsx | 5 |
3 files changed, 19 insertions, 2 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 8a6c872..957c021 100644 --- a/src/Panel.jsx +++ b/src/Panel.jsx | |||
@@ -40,6 +40,7 @@ class Panel extends Component { | |||
40 | onClear: PropTypes.func, | 40 | onClear: PropTypes.func, |
41 | use12Hours: PropTypes.bool, | 41 | use12Hours: PropTypes.bool, |
42 | addon: PropTypes.func, | 42 | addon: PropTypes.func, |
43 | focusOnOpen: PropTypes.bool, | ||
43 | onKeyDown: PropTypes.func, | 44 | onKeyDown: PropTypes.func, |
44 | }; | 45 | }; |
45 | 46 | ||
@@ -91,7 +92,7 @@ class Panel extends Component { | |||
91 | const { | 92 | const { |
92 | prefixCls, className, placeholder, disabledHours, disabledMinutes, | 93 | prefixCls, className, placeholder, disabledHours, disabledMinutes, |
93 | disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, | 94 | disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, |
94 | format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, onKeyDown, | 95 | format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, focusOnOpen, onKeyDown, |
95 | } = this.props; | 96 | } = this.props; |
96 | const { | 97 | const { |
97 | value, currentSelectPanel, | 98 | value, currentSelectPanel, |
@@ -124,6 +125,7 @@ class Panel extends Component { | |||
124 | onChange={this.onChange} | 125 | onChange={this.onChange} |
125 | onClear={onClear} | 126 | onClear={onClear} |
126 | allowEmpty={allowEmpty} | 127 | allowEmpty={allowEmpty} |
128 | focusOnOpen={focusOnOpen} | ||
127 | onKeyDown={onKeyDown} | 129 | onKeyDown={onKeyDown} |
128 | /> | 130 | /> |
129 | <Combobox | 131 | <Combobox |
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx index 271515d..70327d7 100644 --- a/src/TimePicker.jsx +++ b/src/TimePicker.jsx | |||
@@ -48,6 +48,7 @@ export default class Picker extends Component { | |||
48 | name: PropTypes.string, | 48 | name: PropTypes.string, |
49 | autoComplete: PropTypes.string, | 49 | autoComplete: PropTypes.string, |
50 | use12Hours: PropTypes.bool, | 50 | use12Hours: PropTypes.bool, |
51 | focusOnOpen: PropTypes.bool, | ||
51 | onKeyDown: PropTypes.func, | 52 | onKeyDown: PropTypes.func, |
52 | }; | 53 | }; |
53 | 54 | ||
@@ -76,6 +77,7 @@ export default class Picker extends Component { | |||
76 | onBlur: noop, | 77 | onBlur: noop, |
77 | addon: noop, | 78 | addon: noop, |
78 | use12Hours: false, | 79 | use12Hours: false, |
80 | focusOnOpen: false, | ||
79 | onKeyDown: noop, | 81 | onKeyDown: noop, |
80 | }; | 82 | }; |
81 | 83 | ||
@@ -163,7 +165,7 @@ export default class Picker extends Component { | |||
163 | prefixCls, placeholder, disabledHours, | 165 | prefixCls, placeholder, disabledHours, |
164 | disabledMinutes, disabledSeconds, hideDisabledOptions, | 166 | disabledMinutes, disabledSeconds, hideDisabledOptions, |
165 | allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, | 167 | allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, |
166 | addon, use12Hours, onKeyDown, | 168 | addon, use12Hours, focusOnOpen, onKeyDown, |
167 | } = this.props; | 169 | } = this.props; |
168 | return ( | 170 | return ( |
169 | <Panel | 171 | <Panel |
@@ -187,6 +189,7 @@ export default class Picker extends Component { | |||
187 | hideDisabledOptions={hideDisabledOptions} | 189 | hideDisabledOptions={hideDisabledOptions} |
188 | use12Hours={use12Hours} | 190 | use12Hours={use12Hours} |
189 | addon={addon} | 191 | addon={addon} |
192 | focusOnOpen={focusOnOpen} | ||
190 | onKeyDown={onKeyDown} | 193 | onKeyDown={onKeyDown} |
191 | /> | 194 | /> |
192 | ); | 195 | ); |