@@ -161,6 +161,8 @@ type InputSuggestionScrollEventDetail = {
161
161
scrollContainer : HTMLElement ;
162
162
}
163
163
164
+ type CompositionEventHandler = ( e ?: CompositionEvent ) => void ;
165
+
164
166
/**
165
167
* @class
166
168
* ### Overview
@@ -606,6 +608,9 @@ class Input extends UI5Element implements SuggestionComponent, IFormInputElement
606
608
} )
607
609
valueStateMessage ! : Array < HTMLElement > ;
608
610
611
+ _isComposing : boolean ;
612
+ _onCompositionStartBound : CompositionEventHandler ;
613
+ _onCompositionEndBound : CompositionEventHandler ;
609
614
hasSuggestionItemSelected : boolean ;
610
615
valueBeforeItemSelection : string ;
611
616
valueBeforeSelectionStart : string ;
@@ -702,17 +707,43 @@ class Input extends UI5Element implements SuggestionComponent, IFormInputElement
702
707
this . _keepInnerValue = false ;
703
708
this . _focusedAfterClear = false ;
704
709
this . _valueStateLinks = [ ] ;
710
+
711
+ // Used to track if the user is composing text
712
+ this . _isComposing = false ;
713
+
714
+ this . _onCompositionStartBound = this . _onCompositionStart . bind ( this ) ;
715
+ this . _onCompositionEndBound = this . _onCompositionEnd . bind ( this ) ;
705
716
}
706
717
707
718
onEnterDOM ( ) {
708
719
ResizeHandler . register ( this , this . _handleResizeBound ) ;
709
720
registerUI5Element ( this , this . _updateAssociatedLabelsTexts . bind ( this ) ) ;
721
+ const input = this . nativeInput ;
722
+ if ( input ) {
723
+ // Update to JSX bindings when Preact resolves bug with:
724
+ // https://github.com/preactjs/preact/issues/1978
725
+ input . addEventListener ( "compositionstart" , this . _onCompositionStartBound ) ;
726
+ input . addEventListener ( "compositionend" , this . _onCompositionEndBound ) ;
727
+ }
710
728
}
711
729
712
730
onExitDOM ( ) {
713
731
ResizeHandler . deregister ( this , this . _handleResizeBound ) ;
714
732
deregisterUI5Element ( this ) ;
715
733
this . _removeLinksEventListeners ( ) ;
734
+ const input = this . nativeInput ;
735
+ if ( input ) {
736
+ input . removeEventListener ( "compositionstart" , this . _onCompositionStartBound ) ;
737
+ input . removeEventListener ( "compositionend" , this . _onCompositionEndBound ) ;
738
+ }
739
+ }
740
+
741
+ _onCompositionStart ( ) {
742
+ this . _isComposing = true ;
743
+ }
744
+
745
+ _onCompositionEnd ( ) {
746
+ this . _isComposing = false ;
716
747
}
717
748
718
749
_highlightSuggestionItem ( item : SuggestionItem ) {
@@ -773,7 +804,7 @@ class Input extends UI5Element implements SuggestionComponent, IFormInputElement
773
804
774
805
// Typehead causes issues on Android devices, so we disable it for now
775
806
// If there is already a selection the autocomplete has already been performed
776
- if ( this . _shouldAutocomplete && ! isAndroid ( ) && ! autoCompletedChars && ! this . _isKeyNavigation ) {
807
+ if ( this . _shouldAutocomplete && ! isAndroid ( ) && ! autoCompletedChars && ! this . _isKeyNavigation && ! this . _isComposing ) {
777
808
const item = this . _getFirstMatchingItem ( value ) ;
778
809
if ( item ) {
779
810
this . _handleTypeAhead ( item ) ;
0 commit comments