]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
Merge pull request #60 from shoaibbhimani/master
author偏右 <afc163@gmail.com>
Sun, 22 Oct 2017 08:21:13 +0000 (16:21 +0800)
committerGitHub <noreply@github.com>
Sun, 22 Oct 2017 08:21:13 +0000 (16:21 +0800)
Add keydown function on header input

.gitignore
npm-debug.log.1427937311 [deleted file]
src/TimePicker.jsx
tests/TimePicker.spec.jsx

index 2ad822ee30c00d5cadfcc1ab14a999180acdcc78..94761bf701fadf948ddd343324deae0a0a06a762 100644 (file)
@@ -25,4 +25,5 @@ dist
 build
 lib
 es
-coverage
\ No newline at end of file
+coverage
+npm-debug.log.*
diff --git a/npm-debug.log.1427937311 b/npm-debug.log.1427937311
deleted file mode 100644 (file)
index e69de29..0000000
index 0b985dd41b052498bc0e0a69fa436c65d02dcc29..271515da4af3973ac5ed0486c3bbc1f1e8948a6d 100644 (file)
@@ -42,6 +42,8 @@ export default class Picker extends Component {
     onChange: PropTypes.func,
     onOpen: PropTypes.func,
     onClose: PropTypes.func,
+    onFocus: PropTypes.func,
+    onBlur: PropTypes.func,
     addon: PropTypes.func,
     name: PropTypes.string,
     autoComplete: PropTypes.string,
@@ -70,6 +72,8 @@ export default class Picker extends Component {
     onChange: noop,
     onOpen: noop,
     onClose: noop,
+    onFocus: noop,
+    onBlur: noop,
     addon: noop,
     use12Hours: false,
     onKeyDown: noop,
@@ -234,6 +238,7 @@ export default class Picker extends Component {
     const {
       prefixCls, placeholder, placement, align,
       disabled, transitionName, style, className, getPopupContainer, name, autoComplete,
+      onFocus, onBlur,
     } = this.props;
     const { open, value } = this.state;
     const popupClassName = this.getPopupClassName();
@@ -263,6 +268,8 @@ export default class Picker extends Component {
             onKeyDown={this.onKeyDown}
             disabled={disabled} value={value && value.format(this.getFormat()) || ''}
             autoComplete={autoComplete}
+            onFocus={onFocus}
+            onBlur={onBlur}
           />
           <span className={`${prefixCls}-icon`}/>
         </span>
index 0dd6c101ccaf9643c01c24f4b53e2bcd1905fe8c..d698e48ab17b610eeb3fe12491cc9df8ff977526 100644 (file)
@@ -208,4 +208,40 @@ describe('TimePicker', () => {
       });
     });
   });
+
+  describe('other operations', () => {
+    it('focus/blur correctly', (done) => {
+      let focus = false;
+      let blur = false;
+
+      const picker = renderPicker({
+        onFocus: () => {
+          focus = true;
+        },
+        onBlur: () => {
+          blur = true;
+        },
+      });
+      expect(picker.state.open).not.to.be.ok();
+      const input = TestUtils.scryRenderedDOMComponentsWithClass(picker,
+        'rc-time-picker-input')[0];
+
+      async.series([(next) => {
+        Simulate.focus(input);
+        setTimeout(next, 100);
+      }, (next) => {
+        expect(picker.state.open).to.be(false);
+
+        Simulate.blur(input);
+        setTimeout(next, 100);
+      }, (next) => {
+        expect(focus).to.be(true);
+        expect(blur).to.be(true);
+
+        next();
+      }], () => {
+        done();
+      });
+    });
+  });
 });