aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/forms/src/input/index.tsx10
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/forms/src/input/index.tsx b/packages/forms/src/input/index.tsx
index de7e7848e..791e0f360 100644
--- a/packages/forms/src/input/index.tsx
+++ b/packages/forms/src/input/index.tsx
@@ -25,6 +25,7 @@ interface IProps extends React.InputHTMLAttributes<HTMLInputElement>, IFormField
25 showPasswordToggle?: boolean; 25 showPasswordToggle?: boolean;
26 data: IData; 26 data: IData;
27 inputClassName?: string; 27 inputClassName?: string;
28 onEnterKey?: Function;
28} 29}
29 30
30interface IState { 31interface IState {
@@ -80,6 +81,13 @@ class InputComponent extends Component<IProps, IState> {
80 } 81 }
81 } 82 }
82 83
84 onInputKeyPress(e: React.KeyboardEvent) {
85 if (e.key === "Enter") {
86 const { onEnterKey } = this.props;
87 onEnterKey && onEnterKey();
88 }
89 }
90
83 render() { 91 render() {
84 const { 92 const {
85 classes, 93 classes,
@@ -100,6 +108,7 @@ class InputComponent extends Component<IProps, IState> {
100 placeholder, 108 placeholder,
101 spellCheck, 109 spellCheck,
102 onBlur, 110 onBlur,
111 onEnterKey,
103 } = this.props; 112 } = this.props;
104 113
105 const { 114 const {
@@ -144,6 +153,7 @@ class InputComponent extends Component<IProps, IState> {
144 onChange={this.onChange.bind(this)} 153 onChange={this.onChange.bind(this)}
145 onBlur={onBlur} 154 onBlur={onBlur}
146 disabled={disabled} 155 disabled={disabled}
156 onKeyPress={this.onInputKeyPress.bind(this)}
147 /> 157 />
148 {suffix && ( 158 {suffix && (
149 <span className={classes.suffix}> 159 <span className={classes.suffix}>