]> 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)
1  2 
src/TimePicker.jsx

diff --combined src/TimePicker.jsx
index 01bab2c5b5185e33ba0431ac200da40c441725ab,da47ac4d9c211192c985f6dbc0d9c88ae60feb8a..aa3e0da726f009c6e54b69696945b8b382048765
@@@ -41,6 -41,7 +41,7 @@@ const Picker = React.createClass(
      onOpen: PropTypes.func,
      onClose: PropTypes.func,
      addon: PropTypes.func,
+     name: PropTypes.string,
    },
  
    getDefaultProps() {
@@@ -69,6 -70,7 +70,7 @@@
    },
  
    getInitialState() {
+     this.saveInputRef = refFn.bind(this, 'picker');
      this.savePanelRef = refFn.bind(this, 'panelInstance');
      const { defaultOpen, defaultValue, open = defaultOpen, value = defaultValue } = this.props;
      return {
  
    onEsc() {
      this.setOpen(false);
 -    this.picker.focus();
 +    this.focus();
    },
  
    onKeyDown(e) {
      }
    },
  
-     this.refs.picker.focus();
 +  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;
          <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()) || ''}