allowEmpty: PropTypes.bool,
defaultOpenValue: PropTypes.object,
currentSelectPanel: PropTypes.string,
+ focusOnOpen: PropTypes.bool,
+ onKeyDown: PropTypes.func,
};
constructor(props) {
};
}
+ componentDidMount() {
+ if (this.props.focusOnOpen) {
+ // Wait one frame for the panel to be positioned before focusing
+ const requestAnimationFrame = (window.requestAnimationFrame || window.setTimeout);
+ requestAnimationFrame(() => {
+ this.refs.input.focus();
+ this.refs.input.select();
+ });
+ }
+ }
+
componentWillReceiveProps(nextProps) {
const { value, format } = nextProps;
this.setState({
}
onKeyDown = (e) => {
+ const { onEsc, onKeyDown } = this.props;
if (e.keyCode === 27) {
- this.props.onEsc();
+ onEsc();
}
+
+ onKeyDown(e);
}
onClear = () => {
onClear: PropTypes.func,
use12Hours: PropTypes.bool,
addon: PropTypes.func,
+ focusOnOpen: PropTypes.bool,
+ onKeyDown: PropTypes.func,
};
static defaultProps = {
defaultOpenValue: moment(),
use12Hours: false,
addon: noop,
+ onKeyDown: noop,
};
constructor(props) {
const {
prefixCls, className, placeholder, disabledHours, disabledMinutes,
disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond,
- format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, focusOnOpen,
- format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, onKeyDown,
++ format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, focusOnOpen, onKeyDown,
} = this.props;
const {
value, currentSelectPanel,
onChange={this.onChange}
onClear={onClear}
allowEmpty={allowEmpty}
+ focusOnOpen={focusOnOpen}
+ onKeyDown={onKeyDown}
/>
<Combobox
prefixCls={prefixCls}
onChange: PropTypes.func,
onOpen: PropTypes.func,
onClose: PropTypes.func,
+ onFocus: PropTypes.func,
+ onBlur: PropTypes.func,
addon: PropTypes.func,
name: PropTypes.string,
autoComplete: PropTypes.string,
use12Hours: PropTypes.bool,
+ focusOnOpen: PropTypes.bool,
+ onKeyDown: PropTypes.func,
};
static defaultProps = {
onChange: noop,
onOpen: noop,
onClose: noop,
+ onFocus: noop,
+ onBlur: noop,
addon: noop,
use12Hours: false,
+ focusOnOpen: false,
+ onKeyDown: noop,
};
constructor(props) {
prefixCls, placeholder, disabledHours,
disabledMinutes, disabledSeconds, hideDisabledOptions,
allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
- addon, use12Hours, focusOnOpen,
- addon, use12Hours, onKeyDown,
++ addon, use12Hours, focusOnOpen, onKeyDown,
} = this.props;
return (
<Panel
hideDisabledOptions={hideDisabledOptions}
use12Hours={use12Hours}
addon={addon}
+ focusOnOpen={focusOnOpen}
+ onKeyDown={onKeyDown}
/>
);
}
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();
onKeyDown={this.onKeyDown}
disabled={disabled} value={value && value.format(this.getFormat()) || ''}
autoComplete={autoComplete}
+ onFocus={onFocus}
+ onBlur={onBlur}
/>
<span className={`${prefixCls}-icon`}/>
</span>