| name | String | - | sets the name of the generated input |
| onOpen | Function({ open }) | | when TimePicker panel is opened |
| onClose | Function({ open }) | | when TimePicker panel is opened |
+| focusOnOpen | Boolean | false | automatically focus the input when the picker opens |
## Test Case
return (
<div>
<button onClick={this.toggleOpen}>Toggle open</button>
- <TimePicker open={this.state.open} onOpen={this.setOpen} onClose={this.setOpen} />
+ <TimePicker
+ open={this.state.open}
+ onOpen={this.setOpen}
+ onClose={this.setOpen}
+ focusOnOpen
+ />
</div>
);
}
allowEmpty: PropTypes.bool,
defaultOpenValue: PropTypes.object,
currentSelectPanel: PropTypes.string,
+ focusOnOpen: PropTypes.bool,
};
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());
+ }
+ }
+
componentWillReceiveProps(nextProps) {
const { value, format } = nextProps;
this.setState({
onClear: PropTypes.func,
use12Hours: PropTypes.bool,
addon: PropTypes.func,
+ focusOnOpen: PropTypes.bool,
};
static defaultProps = {
const {
prefixCls, className, placeholder, disabledHours, disabledMinutes,
disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond,
- format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear,
+ format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, focusOnOpen,
} = this.props;
const {
value, currentSelectPanel,
onChange={this.onChange}
onClear={onClear}
allowEmpty={allowEmpty}
+ focusOnOpen={focusOnOpen}
/>
<Combobox
prefixCls={prefixCls}
name: PropTypes.string,
autoComplete: PropTypes.string,
use12Hours: PropTypes.bool,
+ focusOnOpen: PropTypes.bool,
};
static defaultProps = {
onClose: noop,
addon: noop,
use12Hours: false,
+ focusOnOpen: false,
};
constructor(props) {
prefixCls, placeholder, disabledHours,
disabledMinutes, disabledSeconds, hideDisabledOptions,
allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
- addon, use12Hours,
+ addon, use12Hours, focusOnOpen,
} = this.props;
return (
<Panel
hideDisabledOptions={hideDisabledOptions}
use12Hours={use12Hours}
addon={addon}
+ focusOnOpen={focusOnOpen}
/>
);
}