diff options
Diffstat (limited to 'packages/forms')
-rw-r--r-- | packages/forms/src/input/index.tsx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/forms/src/input/index.tsx b/packages/forms/src/input/index.tsx index 891ae3b59..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 | ||
30 | interface IState { | 31 | interface 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 | ||
@@ -138,7 +147,7 @@ class InputComponent extends Component<IProps, IState> { | |||
138 | id={id} | 147 | id={id} |
139 | type={inputType} | 148 | type={inputType} |
140 | name={name} | 149 | name={name} |
141 | defaultValue={value as string} | 150 | value={value as string} |
142 | placeholder={placeholder} | 151 | placeholder={placeholder} |
143 | spellCheck={spellCheck} | 152 | spellCheck={spellCheck} |
144 | className={classes.input} | 153 | className={classes.input} |
@@ -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}> |