]> git.immae.eu Git - github/fretlink/time-picker.git/blobdiff - src/TimePicker.jsx
Merge branch 'master' of github.com:react-component/time-picker
[github/fretlink/time-picker.git] / src / TimePicker.jsx
index e6c203159883c361e9628441e69da8fc77d73c78..4d7d4d6c7416c2953711abd6a8b054273de45b7a 100644 (file)
@@ -42,6 +42,7 @@ const Picker = React.createClass({
     onClose: PropTypes.func,
     addon: PropTypes.func,
     name: PropTypes.string,
+    autoComplete: PropTypes.string,
   },
 
   getDefaultProps() {
@@ -70,6 +71,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 {
@@ -105,7 +107,7 @@ const Picker = React.createClass({
 
   onEsc() {
     this.setOpen(false);
-    this.refs.picker.focus();
+    this.focus();
   },
 
   onKeyDown(e) {
@@ -184,11 +186,15 @@ const Picker = React.createClass({
     }
   },
 
+  focus() {
+    this.picker.focus();
+  },
+
   render() {
     const {
       prefixCls, placeholder, placement, align,
       disabled, transitionName, style, className, showHour,
-      showMinute, showSecond, getPopupContainer, name,
+      showMinute, showSecond, getPopupContainer, name, autoComplete,
     } = this.props;
     const { open, value } = this.state;
     let popupClassName;
@@ -213,11 +219,14 @@ 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()) || ''}
+            autoComplete={autoComplete}
           />
           <span className={`${prefixCls}-icon`}/>
         </span>