@@ -547,7 +547,7 @@ class Input extends UI5Element {
547
547
}
548
548
}
549
549
550
- onAfterRendering ( ) {
550
+ async onAfterRendering ( ) {
551
551
if ( ! this . firstRendering && ! isPhone ( ) && this . Suggestions ) {
552
552
const shouldOpenSuggestions = this . shouldOpenSuggestions ( ) ;
553
553
@@ -562,7 +562,8 @@ class Input extends UI5Element {
562
562
563
563
if ( ! isPhone ( ) && shouldOpenSuggestions ) {
564
564
// Set initial focus to the native input
565
- this . inputDomRef && this . inputDomRef . focus ( ) ;
565
+
566
+ ( await this . getInputDOMRef ( ) ) . focus ( ) ;
566
567
}
567
568
}
568
569
@@ -648,9 +649,7 @@ class Input extends UI5Element {
648
649
return ;
649
650
}
650
651
651
- if ( this . popover ) {
652
- this . popover . close ( ) ;
653
- }
652
+ this . closePopover ( ) ;
654
653
655
654
this . previousValue = "" ;
656
655
this . focused = false ; // invalidating property
@@ -677,8 +676,9 @@ class Input extends UI5Element {
677
676
}
678
677
679
678
async _handleInput ( event ) {
680
- await this . getInputDOMRef ( ) ;
681
- if ( event . target === this . inputDomRef ) {
679
+ const inputDomRef = await this . getInputDOMRef ( ) ;
680
+
681
+ if ( event . target === inputDomRef ) {
682
682
// stop the native event, as the semantic "input" would be fired.
683
683
event . stopImmediatePropagation ( ) ;
684
684
}
@@ -687,7 +687,7 @@ class Input extends UI5Element {
687
687
- value of the host and the internal input should be differnt in case of actual input
688
688
- input is called when a key is pressed => keyup should not be called yet
689
689
*/
690
- const skipFiring = ( this . inputDomRef . value === this . value ) && isIE ( ) && ! this . _keyDown && ! ! this . placeholder ;
690
+ const skipFiring = ( inputDomRef . value === this . value ) && isIE ( ) && ! this . _keyDown && ! ! this . placeholder ;
691
691
692
692
! skipFiring && this . fireEventByAction ( this . ACTION_USER_INPUT ) ;
693
693
@@ -709,8 +709,7 @@ class Input extends UI5Element {
709
709
async _afterOpenPopover ( ) {
710
710
// Set initial focus to the native input
711
711
if ( isPhone ( ) ) {
712
- await this . getInputDOMRef ( ) ;
713
- this . inputDomRef . focus ( ) ;
712
+ ( await this . getInputDOMRef ( ) ) . focus ( ) ;
714
713
}
715
714
}
716
715
@@ -741,18 +740,18 @@ class Input extends UI5Element {
741
740
}
742
741
743
742
async openPopover ( ) {
744
- this . popover = await this . _getPopover ( ) ;
745
- if ( this . popover ) {
743
+ const popover = await this . _getPopover ( ) ;
744
+
745
+ if ( popover ) {
746
746
this . _isPopoverOpen = true ;
747
- this . popover . openBy ( this ) ;
747
+ popover . openBy ( this ) ;
748
748
}
749
749
}
750
750
751
- closePopover ( ) {
752
- if ( this . isOpen ( ) ) {
753
- this . _isPopoverOpen = false ;
754
- this . popover && this . popover . close ( ) ;
755
- }
751
+ async closePopover ( ) {
752
+ const popover = await this . _getPopover ( ) ;
753
+
754
+ popover && popover . close ( ) ;
756
755
}
757
756
758
757
async _getPopover ( ) {
@@ -791,14 +790,15 @@ class Input extends UI5Element {
791
790
? this . valueBeforeItemSelection !== itemText : this . value !== itemText ;
792
791
793
792
this . hasSuggestionItemSelected = true ;
794
- this . fireEvent ( this . EVENT_SUGGESTION_ITEM_SELECT , { item } ) ;
795
793
796
794
if ( fireInput ) {
797
795
this . value = itemText ;
798
796
this . valueBeforeItemSelection = itemText ;
799
797
this . fireEvent ( this . EVENT_INPUT ) ;
800
798
this . fireEvent ( this . EVENT_CHANGE ) ;
801
799
}
800
+
801
+ this . fireEvent ( this . EVENT_SUGGESTION_ITEM_SELECT , { item } ) ;
802
802
}
803
803
804
804
previewSuggestion ( item ) {
@@ -839,7 +839,7 @@ class Input extends UI5Element {
839
839
return ;
840
840
}
841
841
842
- const inputValue = this . getInputValue ( ) ;
842
+ const inputValue = await this . getInputValue ( ) ;
843
843
const isSubmit = action === this . ACTION_ENTER ;
844
844
const isUserInput = action === this . ACTION_USER_INPUT ;
845
845
@@ -875,28 +875,22 @@ class Input extends UI5Element {
875
875
}
876
876
}
877
877
878
- getInputValue ( ) {
879
- const inputDOM = this . getDomRef ( ) ;
880
- if ( inputDOM ) {
881
- return this . inputDomRef . value ;
878
+ async getInputValue ( ) {
879
+ const domRef = this . getDomRef ( ) ;
880
+
881
+ if ( domRef ) {
882
+ return ( await this . getInputDOMRef ( ) ) . value ;
882
883
}
883
884
return "" ;
884
885
}
885
886
886
887
async getInputDOMRef ( ) {
887
- let inputDomRef ;
888
-
889
- if ( isPhone ( ) && this . Suggestions ) {
888
+ if ( isPhone ( ) && this . Suggestions && this . suggestionItems . length ) {
890
889
await this . Suggestions . _respPopover ( ) ;
891
- inputDomRef = this . Suggestions && this . Suggestions . responsivePopover . querySelector ( ".ui5-input-inner-phone" ) ;
892
- }
893
-
894
- if ( ! inputDomRef ) {
895
- inputDomRef = this . getDomRef ( ) . querySelector ( `#${ this . getInputId ( ) } ` ) ;
890
+ return this . Suggestions && this . Suggestions . responsivePopover . querySelector ( ".ui5-input-inner-phone" ) ;
896
891
}
897
892
898
- this . inputDomRef = inputDomRef ;
899
- return this . inputDomRef ;
893
+ return this . getDomRef ( ) . querySelector ( `input` ) ;
900
894
}
901
895
902
896
getLabelableElementId ( ) {
0 commit comments