From: 偏右 Date: Sun, 22 Oct 2017 08:21:13 +0000 (+0800) Subject: Merge pull request #60 from shoaibbhimani/master X-Git-Tag: 3.0.0~8 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=2fb27d673619b7bdd70178e617965a009fa72874;hp=6022baedfba9ec831d9fddaf7979771a71ca7fb8;p=github%2Ffretlink%2Ftime-picker.git Merge pull request #60 from shoaibbhimani/master Add keydown function on header input --- diff --git a/src/Header.jsx b/src/Header.jsx index 91e8549..f6dd241 100644 --- a/src/Header.jsx +++ b/src/Header.jsx @@ -22,6 +22,7 @@ class Header extends Component { allowEmpty: PropTypes.bool, defaultOpenValue: PropTypes.object, currentSelectPanel: PropTypes.string, + onKeyDown: PropTypes.func, }; constructor(props) { @@ -122,9 +123,12 @@ class Header extends Component { } onKeyDown = (e) => { + const { onEsc, onKeyDown } = this.props; if (e.keyCode === 27) { - this.props.onEsc(); + onEsc(); } + + onKeyDown(e); } onClear = () => { diff --git a/src/Panel.jsx b/src/Panel.jsx index 1953ad4..8a6c872 100644 --- a/src/Panel.jsx +++ b/src/Panel.jsx @@ -40,6 +40,7 @@ class Panel extends Component { onClear: PropTypes.func, use12Hours: PropTypes.bool, addon: PropTypes.func, + onKeyDown: PropTypes.func, }; static defaultProps = { @@ -52,6 +53,7 @@ class Panel extends Component { defaultOpenValue: moment(), use12Hours: false, addon: noop, + onKeyDown: noop, }; constructor(props) { @@ -89,7 +91,7 @@ class Panel extends Component { 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, onKeyDown, } = this.props; const { value, currentSelectPanel, @@ -122,6 +124,7 @@ class Panel extends Component { onChange={this.onChange} onClear={onClear} allowEmpty={allowEmpty} + onKeyDown={onKeyDown} /> ); }