@@ -724,7 +724,7 @@ class MultiComboBox extends UI5Element {
724
724
}
725
725
726
726
if ( isInsertShift ( e ) ) {
727
- this . _handleInsertPaste ( ) ;
727
+ this . _handleInsertPaste ( e ) ;
728
728
return ;
729
729
}
730
730
@@ -756,9 +756,22 @@ class MultiComboBox extends UI5Element {
756
756
this . _shouldAutocomplete = ! this . noTypeahead && ! ( isBackSpace ( e ) || isDelete ( e ) || isEscape ( e ) || isEnter ( e ) ) ;
757
757
}
758
758
759
- _handlePaste ( e : ClipboardEvent ) {
760
- e . preventDefault ( ) ;
759
+ _selectItems ( matchingItems : IMultiComboBoxItem [ ] ) {
760
+ this . _previouslySelectedItems = this . _getSelectedItems ( ) ;
761
761
762
+ matchingItems . forEach ( item => {
763
+ item . selected = true ;
764
+ this . value = "" ;
765
+
766
+ const changePrevented = this . fireSelectionChange ( ) ;
767
+
768
+ if ( changePrevented ) {
769
+ this . _revertSelection ( ) ;
770
+ }
771
+ } ) ;
772
+ }
773
+
774
+ _handlePaste ( e : ClipboardEvent ) {
762
775
if ( this . readonly || ! e . clipboardData ) {
763
776
return ;
764
777
}
@@ -769,10 +782,20 @@ class MultiComboBox extends UI5Element {
769
782
return ;
770
783
}
771
784
772
- this . _createTokenFromText ( pastedText ) ;
785
+ this . _handleTokenCreationUponPaste ( pastedText , e ) ;
786
+ }
787
+
788
+ _handleTokenCreationUponPaste ( pastedText : string , e : KeyboardEvent | ClipboardEvent ) {
789
+ const separatedText = pastedText . split ( / \r \n | \r | \n | \t / g) . filter ( t => ! ! t ) ;
790
+ const matchingItems = this . items . filter ( item => separatedText . includes ( item . text ) && ! item . selected ) ;
791
+
792
+ if ( matchingItems . length > 1 ) {
793
+ e . preventDefault ( ) ;
794
+ this . _selectItems ( matchingItems ) ;
795
+ }
773
796
}
774
797
775
- async _handleInsertPaste ( ) {
798
+ async _handleInsertPaste ( e : KeyboardEvent ) {
776
799
if ( this . readonly || isFirefox ( ) ) {
777
800
return ;
778
801
}
@@ -783,29 +806,7 @@ class MultiComboBox extends UI5Element {
783
806
return ;
784
807
}
785
808
786
- this . _createTokenFromText ( pastedText ) ;
787
- }
788
-
789
- _createTokenFromText ( pastedText : string ) {
790
- const separatedText = pastedText . split ( / \r \n | \r | \n | \t / g) . filter ( t => ! ! t ) ;
791
- const matchingItems = this . items . filter ( item => separatedText . indexOf ( item . text ) > - 1 && ! item . selected ) ;
792
-
793
- if ( separatedText . length > 1 ) {
794
- this . _previouslySelectedItems = this . _getSelectedItems ( ) ;
795
- matchingItems . forEach ( item => {
796
- item . selected = true ;
797
- this . value = "" ;
798
-
799
- const changePrevented = this . fireSelectionChange ( ) ;
800
-
801
- if ( changePrevented ) {
802
- this . _revertSelection ( ) ;
803
- }
804
- } ) ;
805
- } else {
806
- this . value = pastedText ;
807
- this . fireEvent ( "input" ) ;
808
- }
809
+ this . _handleTokenCreationUponPaste ( pastedText , e ) ;
809
810
}
810
811
811
812
_handleShow ( e : KeyboardEvent ) {
@@ -1260,7 +1261,7 @@ class MultiComboBox extends UI5Element {
1260
1261
}
1261
1262
1262
1263
if ( isInsertShift ( e ) ) {
1263
- this . _handleInsertPaste ( ) ;
1264
+ this . _handleInsertPaste ( e ) ;
1264
1265
}
1265
1266
1266
1267
if ( isHome ( e ) ) {
0 commit comments