8
8
9
9
import React , {
10
10
Component ,
11
- ChangeEventHandler ,
12
11
FocusEventHandler ,
13
12
KeyboardEventHandler ,
14
13
RefCallback ,
@@ -44,9 +43,9 @@ export interface EuiComboBoxInputProps<T> extends CommonProps {
44
43
isListOpen : boolean ;
45
44
noIcon : boolean ;
46
45
onBlur ?: FocusEventHandler < HTMLInputElement > ;
47
- onChange ? : ( searchValue : string ) => void ;
46
+ onChange : ( searchValue : string ) => void ;
48
47
onClear ?: ( ) => void ;
49
- onClick ? : ( ) => void ;
48
+ onClick : ( ) => void ;
50
49
onCloseListClick : ( ) => void ;
51
50
onFocus : FocusEventHandler < HTMLInputElement > ;
52
51
onOpenListClick : ( ) => void ;
@@ -147,22 +146,15 @@ export class EuiComboBoxInput<T> extends Component<
147
146
} ;
148
147
149
148
componentDidUpdate ( prevProps : EuiComboBoxInputProps < T > ) {
150
- const { searchValue } = prevProps ;
149
+ if ( prevProps . searchValue !== this . props . searchValue ) {
150
+ this . updateInputSize ( this . props . searchValue ) ;
151
151
152
- // We need to update the position of everything if the user enters enough input to change
153
- // the size of the input.
154
- if ( searchValue !== this . props . searchValue ) {
152
+ // We need to update the position of everything if the user enters enough input to change
153
+ // the size of the input.
155
154
this . updatePosition ( ) ;
156
155
}
157
156
}
158
157
159
- inputOnChange : ChangeEventHandler < HTMLInputElement > = ( event ) => {
160
- const { value } = event . target ;
161
-
162
- this . updateInputSize ( value ) ;
163
- this . props . onChange ?.( value ) ;
164
- } ;
165
-
166
158
render ( ) {
167
159
const {
168
160
compressed,
@@ -173,6 +165,7 @@ export class EuiComboBoxInput<T> extends Component<
173
165
isDisabled,
174
166
isListOpen,
175
167
noIcon,
168
+ onChange,
176
169
onClear,
177
170
onClick,
178
171
onCloseListClick,
@@ -350,7 +343,7 @@ export class EuiComboBoxInput<T> extends Component<
350
343
disabled = { isDisabled }
351
344
id = { id }
352
345
onBlur = { this . onBlur }
353
- onChange = { this . inputOnChange }
346
+ onChange = { ( event ) => onChange ( event . target . value ) }
354
347
onFocus = { this . onFocus }
355
348
onKeyDown = { this . onKeyDown }
356
349
ref = { this . inputRefCallback }
0 commit comments