diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | npm-debug.log.1427937311 | 0 | ||||
-rw-r--r-- | src/TimePicker.jsx | 7 | ||||
-rw-r--r-- | tests/TimePicker.spec.jsx | 36 |
4 files changed, 45 insertions, 1 deletions
@@ -25,4 +25,5 @@ dist | |||
25 | build | 25 | build |
26 | lib | 26 | lib |
27 | es | 27 | es |
28 | coverage \ No newline at end of file | 28 | coverage |
29 | npm-debug.log.* | ||
diff --git a/npm-debug.log.1427937311 b/npm-debug.log.1427937311 deleted file mode 100644 index e69de29..0000000 --- a/npm-debug.log.1427937311 +++ /dev/null | |||
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx index 0b985dd..271515d 100644 --- a/src/TimePicker.jsx +++ b/src/TimePicker.jsx | |||
@@ -42,6 +42,8 @@ export default class Picker extends Component { | |||
42 | onChange: PropTypes.func, | 42 | onChange: PropTypes.func, |
43 | onOpen: PropTypes.func, | 43 | onOpen: PropTypes.func, |
44 | onClose: PropTypes.func, | 44 | onClose: PropTypes.func, |
45 | onFocus: PropTypes.func, | ||
46 | onBlur: PropTypes.func, | ||
45 | addon: PropTypes.func, | 47 | addon: PropTypes.func, |
46 | name: PropTypes.string, | 48 | name: PropTypes.string, |
47 | autoComplete: PropTypes.string, | 49 | autoComplete: PropTypes.string, |
@@ -70,6 +72,8 @@ export default class Picker extends Component { | |||
70 | onChange: noop, | 72 | onChange: noop, |
71 | onOpen: noop, | 73 | onOpen: noop, |
72 | onClose: noop, | 74 | onClose: noop, |
75 | onFocus: noop, | ||
76 | onBlur: noop, | ||
73 | addon: noop, | 77 | addon: noop, |
74 | use12Hours: false, | 78 | use12Hours: false, |
75 | onKeyDown: noop, | 79 | onKeyDown: noop, |
@@ -234,6 +238,7 @@ export default class Picker extends Component { | |||
234 | const { | 238 | const { |
235 | prefixCls, placeholder, placement, align, | 239 | prefixCls, placeholder, placement, align, |
236 | disabled, transitionName, style, className, getPopupContainer, name, autoComplete, | 240 | disabled, transitionName, style, className, getPopupContainer, name, autoComplete, |
241 | onFocus, onBlur, | ||
237 | } = this.props; | 242 | } = this.props; |
238 | const { open, value } = this.state; | 243 | const { open, value } = this.state; |
239 | const popupClassName = this.getPopupClassName(); | 244 | const popupClassName = this.getPopupClassName(); |
@@ -263,6 +268,8 @@ export default class Picker extends Component { | |||
263 | onKeyDown={this.onKeyDown} | 268 | onKeyDown={this.onKeyDown} |
264 | disabled={disabled} value={value && value.format(this.getFormat()) || ''} | 269 | disabled={disabled} value={value && value.format(this.getFormat()) || ''} |
265 | autoComplete={autoComplete} | 270 | autoComplete={autoComplete} |
271 | onFocus={onFocus} | ||
272 | onBlur={onBlur} | ||
266 | /> | 273 | /> |
267 | <span className={`${prefixCls}-icon`}/> | 274 | <span className={`${prefixCls}-icon`}/> |
268 | </span> | 275 | </span> |
diff --git a/tests/TimePicker.spec.jsx b/tests/TimePicker.spec.jsx index 0dd6c10..d698e48 100644 --- a/tests/TimePicker.spec.jsx +++ b/tests/TimePicker.spec.jsx | |||
@@ -208,4 +208,40 @@ describe('TimePicker', () => { | |||
208 | }); | 208 | }); |
209 | }); | 209 | }); |
210 | }); | 210 | }); |
211 | |||
212 | describe('other operations', () => { | ||
213 | it('focus/blur correctly', (done) => { | ||
214 | let focus = false; | ||
215 | let blur = false; | ||
216 | |||
217 | const picker = renderPicker({ | ||
218 | onFocus: () => { | ||
219 | focus = true; | ||
220 | }, | ||
221 | onBlur: () => { | ||
222 | blur = true; | ||
223 | }, | ||
224 | }); | ||
225 | expect(picker.state.open).not.to.be.ok(); | ||
226 | const input = TestUtils.scryRenderedDOMComponentsWithClass(picker, | ||
227 | 'rc-time-picker-input')[0]; | ||
228 | |||
229 | async.series([(next) => { | ||
230 | Simulate.focus(input); | ||
231 | setTimeout(next, 100); | ||
232 | }, (next) => { | ||
233 | expect(picker.state.open).to.be(false); | ||
234 | |||
235 | Simulate.blur(input); | ||
236 | setTimeout(next, 100); | ||
237 | }, (next) => { | ||
238 | expect(focus).to.be(true); | ||
239 | expect(blur).to.be(true); | ||
240 | |||
241 | next(); | ||
242 | }], () => { | ||
243 | done(); | ||
244 | }); | ||
245 | }); | ||
246 | }); | ||
211 | }); | 247 | }); |