diff options
Diffstat (limited to 'packages/forms/src/input/index.tsx')
-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 5178904d3..a2d7c62d5 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 { |
@@ -33,7 +34,7 @@ interface IState { | |||
33 | } | 34 | } |
34 | 35 | ||
35 | class InputComponent extends Component<IProps, IState> { | 36 | class InputComponent extends Component<IProps, IState> { |
36 | public static defaultProps = { | 37 | static defaultProps = { |
37 | focus: false, | 38 | focus: false, |
38 | onChange: () => {}, | 39 | onChange: () => {}, |
39 | onBlur: () => {}, | 40 | onBlur: () => {}, |
@@ -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, |
@@ -124,6 +132,7 @@ class InputComponent extends Component<IProps, IState> { | |||
124 | title={label} | 132 | title={label} |
125 | showLabel={showLabel} | 133 | showLabel={showLabel} |
126 | htmlFor={id} | 134 | htmlFor={id} |
135 | className={classes.label} | ||
127 | isRequired={required} | 136 | isRequired={required} |
128 | > | 137 | > |
129 | <div | 138 | <div |
@@ -152,6 +161,7 @@ class InputComponent extends Component<IProps, IState> { | |||
152 | onFocus={onFocus} | 161 | onFocus={onFocus} |
153 | onBlur={onBlur} | 162 | onBlur={onBlur} |
154 | disabled={disabled} | 163 | disabled={disabled} |
164 | onKeyPress={this.onInputKeyPress.bind(this)} | ||
155 | min={min} | 165 | min={min} |
156 | max={max} | 166 | max={max} |
157 | step={step} | 167 | step={step} |