@@ -180,6 +180,10 @@ const metadata = {
180
180
type : Boolean ,
181
181
} ,
182
182
183
+ _input : {
184
+ type : Object ,
185
+ } ,
186
+
183
187
_popover : {
184
188
type : Object ,
185
189
} ,
@@ -200,7 +204,7 @@ const metadata = {
200
204
* @event
201
205
* @public
202
206
*/
203
- liveChange : { } ,
207
+ input : { } ,
204
208
205
209
/**
206
210
* Fired when user presses Enter key on the <code>ui5-input</code>.
@@ -288,7 +292,7 @@ class Input extends WebComponent {
288
292
this . previousValue = undefined ;
289
293
290
294
// Represents the value before user moves selection between the suggestion items.
291
- // Used to register and fire "liveChange " event upon [SPACE] or [ENTER].
295
+ // Used to register and fire "input " event upon [SPACE] or [ENTER].
292
296
// Note: the property "value" is updated upon selection move and can`t be used.
293
297
this . valueBeforeItemSelection = "" ;
294
298
@@ -298,15 +302,19 @@ class Input extends WebComponent {
298
302
// all sementic events
299
303
this . EVENT_SUBMIT = "submit" ;
300
304
this . EVENT_CHANGE = "change" ;
301
- this . EVENT_LIVE_CHANGE = "liveChange " ;
305
+ this . EVENT_INPUT = "input " ;
302
306
this . EVENT_SUGGESTION_ITEM_SELECT = "suggestionItemSelect" ;
303
307
304
308
// all user interactions
305
- this . ACTION_INPUT = "input" ;
306
309
this . ACTION_ENTER = "enter" ;
307
310
this . ACTION_FOCUSOUT = "focusOut" ;
311
+ this . ACTION_USER_INPUT = "input" ;
308
312
309
- this . _whenShadowRootReady ( ) . then ( this . attachFocusHandler . bind ( this ) ) ;
313
+ this . _input = {
314
+ onInput : this . _onInput . bind ( this ) ,
315
+ } ;
316
+
317
+ this . _whenShadowRootReady ( ) . then ( this . attachFocusHandlers . bind ( this ) ) ;
310
318
}
311
319
312
320
onBeforeRendering ( ) {
@@ -393,8 +401,13 @@ class Input extends WebComponent {
393
401
this . _focused = false ; // invalidating property
394
402
}
395
403
396
- oninput ( ) {
397
- this . fireEventByAction ( this . ACTION_INPUT ) ;
404
+ _onInput ( event ) {
405
+ if ( event . target === this . getInputDOMRef ( ) ) {
406
+ // stop the native event, as the semantic "input" would be fired.
407
+ event . stopImmediatePropagation ( ) ;
408
+ }
409
+
410
+ this . fireEventByAction ( this . ACTION_USER_INPUT ) ;
398
411
this . hasSuggestionItemSelected = false ;
399
412
400
413
if ( this . Suggestions ) {
@@ -403,7 +416,7 @@ class Input extends WebComponent {
403
416
}
404
417
405
418
/* Private Methods */
406
- attachFocusHandler ( ) {
419
+ attachFocusHandlers ( ) {
407
420
this . shadowRoot . addEventListener ( "focusout" , this . onfocusout . bind ( this ) ) ;
408
421
this . shadowRoot . addEventListener ( "focusin" , this . onfocusin . bind ( this ) ) ;
409
422
}
@@ -430,17 +443,17 @@ class Input extends WebComponent {
430
443
431
444
selectSuggestion ( item , keyboardUsed ) {
432
445
const itemText = item . _nodeText ;
433
- const fireLiveChange = keyboardUsed
446
+ const fireInput = keyboardUsed
434
447
? this . valueBeforeItemSelection !== itemText : this . value !== itemText ;
435
448
436
449
item . selected = false ;
437
450
this . hasSuggestionItemSelected = true ;
438
451
this . fireEvent ( this . EVENT_SUGGESTION_ITEM_SELECT , { item } ) ;
439
452
440
- if ( fireLiveChange ) {
453
+ if ( fireInput ) {
441
454
this . value = itemText ;
442
455
this . valueBeforeItemSelection = itemText ;
443
- this . fireEvent ( this . EVENT_LIVE_CHANGE ) ;
456
+ this . fireEvent ( this . EVENT_INPUT ) ;
444
457
}
445
458
}
446
459
@@ -457,14 +470,14 @@ class Input extends WebComponent {
457
470
const inputValue = this . getInputValue ( ) ;
458
471
const isSubmit = action === this . ACTION_ENTER ;
459
472
const isFocusOut = action === this . ACTION_FOCUSOUT ;
460
- const isInput = action === this . ACTION_INPUT ;
473
+ const isUserInput = action === this . ACTION_USER_INPUT ;
461
474
462
475
this . value = inputValue ;
463
476
464
477
const valueChanged = ( this . previousValue !== undefined ) && ( this . previousValue !== this . value ) ;
465
478
466
- if ( isInput ) { // liveChange
467
- this . fireEvent ( this . EVENT_LIVE_CHANGE ) ;
479
+ if ( isUserInput ) { // input
480
+ this . fireEvent ( this . EVENT_INPUT ) ;
468
481
return ;
469
482
}
470
483
0 commit comments