From 0e4fd1626e460bd52a82de3f12f84d88f652dd7e Mon Sep 17 00:00:00 2001 From: shoaibbhimani Date: Thu, 24 Aug 2017 16:41:19 +0530 Subject: Add keydown function on header input --- src/Header.jsx | 6 +++++- src/Panel.jsx | 5 ++++- src/TimePicker.jsx | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) 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} /> ); } -- cgit v1.2.3