]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
Merge branch 'master' into feat-focus
author偏右 <afc163@gmail.com>
Mon, 20 Feb 2017 08:03:41 +0000 (16:03 +0800)
committerGitHub <noreply@github.com>
Mon, 20 Feb 2017 08:03:41 +0000 (16:03 +0800)
.travis.yml
README.md
src/TimePicker.jsx

index e780b32b66b3c26b84f4c1aa7f5b9a01edb60e85..d2c1fdb863419da08203b8ac642676ed5cef6a72 100644 (file)
@@ -7,7 +7,7 @@ notifications:
   - yiminghe@gmail.com
 
 node_js:
-- 4.0.0
+- 6
 
 before_install:
 - |
index 05182c210e75811550d9de4c29a6daa4728e2c9c..4a368151a09f582c0674f0a3134859e0d8384249 100644 (file)
--- a/README.md
+++ b/README.md
@@ -71,6 +71,7 @@ API
 | addon                   | Function                          | nothing                                       | called from timepicker panel to render some addon to its bottom, like an OK button. Receives panel instance as parameter, to be able to close it like `panel.close()`.|
 | placement               | String                            | bottomLeft                                    | one of ['left','right','top','bottom', 'topLeft', 'topRight', 'bottomLeft', 'bottomRight'] |
 | transitionName          | String                            | ''                                            |                                                                                            |
+| name                    | String                            | nothing                                       | sets the name of the generated input                                                       |
 
 
 ## Test Case
index 01bab2c5b5185e33ba0431ac200da40c441725ab..aa3e0da726f009c6e54b69696945b8b382048765 100644 (file)
@@ -41,6 +41,7 @@ const Picker = React.createClass({
     onOpen: PropTypes.func,
     onClose: PropTypes.func,
     addon: PropTypes.func,
+    name: PropTypes.string,
   },
 
   getDefaultProps() {
@@ -69,6 +70,7 @@ const Picker = React.createClass({
   },
 
   getInitialState() {
+    this.saveInputRef = refFn.bind(this, 'picker');
     this.savePanelRef = refFn.bind(this, 'panelInstance');
     const { defaultOpen, defaultValue, open = defaultOpen, value = defaultValue } = this.props;
     return {
@@ -184,14 +186,14 @@ const Picker = React.createClass({
   },
 
   focus() {
-    this.refs.picker.focus();
+    this.picker.focus();
   },
 
   render() {
     const {
       prefixCls, placeholder, placement, align,
       disabled, transitionName, style, className, showHour,
-      showMinute, showSecond, getPopupContainer,
+      showMinute, showSecond, getPopupContainer, name,
     } = this.props;
     const { open, value } = this.state;
     let popupClassName;
@@ -216,7 +218,10 @@ const Picker = React.createClass({
         <span className={`${prefixCls} ${className}`} style={style}>
           <input
             className={`${prefixCls}-input`}
-            ref="picker" type="text" placeholder={placeholder}
+            ref={this.saveInputRef}
+            type="text"
+            placeholder={placeholder}
+            name={name}
             readOnly
             onKeyDown={this.onKeyDown}
             disabled={disabled} value={value && value.format(this.getFormat()) || ''}