aboutsummaryrefslogtreecommitdiffstats
path: root/packages/forms/src/input/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/forms/src/input/index.tsx')
-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 478738cad..cc3709b1a 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 {
@@ -81,6 +82,13 @@ class InputComponent extends Component<IProps, IState> {
81 } 82 }
82 } 83 }
83 84
85 onInputKeyPress(e: React.KeyboardEvent) {
86 if (e.key === "Enter") {
87 const { onEnterKey } = this.props;
88 onEnterKey && onEnterKey();
89 }
90 }
91
84 render() { 92 render() {
85 const { 93 const {
86 classes, 94 classes,
@@ -101,6 +109,7 @@ class InputComponent extends Component<IProps, IState> {
101 placeholder, 109 placeholder,
102 spellCheck, 110 spellCheck,
103 onBlur, 111 onBlur,
112 onEnterKey,
104 onFocus, 113 onFocus,
105 } = this.props; 114 } = this.props;
106 115
@@ -147,6 +156,7 @@ class InputComponent extends Component<IProps, IState> {
147 onFocus={onFocus} 156 onFocus={onFocus}
148 onBlur={onBlur} 157 onBlur={onBlur}
149 disabled={disabled} 158 disabled={disabled}
159 onKeyPress={this.onInputKeyPress.bind(this)}
150 /> 160 />
151 {suffix && ( 161 {suffix && (
152 <span className={classes.suffix}> 162 <span className={classes.suffix}>