@@ -18,14 +18,13 @@ import {
1818 isPageDown ,
1919 isHome ,
2020 isEnd ,
21- isRight ,
2221 isTabPrevious ,
2322} from "@ui5/webcomponents-base/dist/Keys.js" ;
2423
2524import SearchTemplate from "./SearchTemplate.js" ;
2625import SearchCss from "./generated/themes/Search.css.js" ;
2726import SearchField from "./SearchField.js" ;
28- import { StartsWith , StartsWithPerTerm } from "@ui5/webcomponents/dist/Filters.js" ;
27+ import { StartsWith } from "@ui5/webcomponents/dist/Filters.js" ;
2928import type UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js" ;
3029import type SearchItem from "./SearchItem.js" ;
3130import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js" ;
@@ -208,12 +207,6 @@ class Search extends SearchField {
208207 */
209208 _valueBeforeOpen : string ;
210209
211- /**
212- * True if the first matching item is matched by starts with per term, rather than by starts with.
213- * @private
214- */
215- _matchedPerTerm : boolean ;
216-
217210 /**
218211 * Holds the currently proposed item which will be selected if the user presses Enter.
219212 * @private
@@ -228,7 +221,6 @@ class Search extends SearchField {
228221
229222 // The typed in value.
230223 this . _typedInValue = "" ;
231- this . _matchedPerTerm = false ;
232224 this . _valueBeforeOpen = this . getAttribute ( "value" ) || "" ;
233225 }
234226
@@ -317,29 +309,17 @@ class Search extends SearchField {
317309
318310 _handleTypeAhead ( item : ISearchSuggestionItem ) {
319311 const originalValue = item . text || "" ;
320- let displayValue = originalValue ;
321-
322- if ( ! originalValue . toLowerCase ( ) . startsWith ( this . value . toLowerCase ( ) ) ) {
323- this . _matchedPerTerm = true ;
324- displayValue = `${ this . value } - ${ originalValue } ` ;
325- } else {
326- this . _matchedPerTerm = false ;
327- }
328312
329313 this . _typedInValue = this . value ;
330- this . _innerValue = displayValue ;
314+ this . _innerValue = originalValue ;
331315 this . _performTextSelection = true ;
332- this . value = displayValue ;
316+ this . value = originalValue ;
333317 }
334318
335319 _startsWithMatchingItems ( str : string ) : Array < ISearchSuggestionItem > {
336320 return StartsWith ( str , this . _flattenItems . filter ( item => ! this . _isGroupItem ( item ) && ! this . _isShowMoreItem ( item ) ) , "text" ) ;
337321 }
338322
339- _startsWithPerTermMatchingItems ( str : string ) : Array < ISearchSuggestionItem > {
340- return StartsWithPerTerm ( str , this . _flattenItems . filter ( item => ! this . _isGroupItem ( item ) && ! this . _isShowMoreItem ( item ) ) , "text" ) ;
341- }
342-
343323 _isGroupItem ( item : HTMLElement ) : item is SearchItemGroup {
344324 return item . hasAttribute ( "ui5-search-item-group" ) ;
345325 }
@@ -374,15 +354,6 @@ class Search extends SearchField {
374354 }
375355 }
376356
377- _handleRight ( e : KeyboardEvent ) {
378- if ( this . _matchedPerTerm ) {
379- e . preventDefault ( ) ;
380- this . value = this . _typedInValue ;
381- this . _innerValue = this . _typedInValue ;
382- this . _proposedItem = undefined ;
383- }
384- }
385-
386357 _handleInnerClick ( ) {
387358 if ( isPhone ( ) ) {
388359 this . open = true ;
@@ -405,12 +376,6 @@ class Search extends SearchField {
405376 }
406377
407378 const innerInput = this . nativeInput ! ;
408- if ( this . _matchedPerTerm ) {
409- this . value = this . _proposedItem ?. text || this . value ;
410- this . _innerValue = this . value ;
411- this . _typedInValue = this . value ;
412- this . _matchedPerTerm = false ;
413- }
414379
415380 innerInput . setSelectionRange ( this . value . length , this . value . length ) ;
416381 this . open = false ;
@@ -510,10 +475,6 @@ class Search extends SearchField {
510475 this . _shouldAutocomplete = ! this . noTypeahead
511476 && ! ( isBackSpace ( e ) || isDelete ( e ) || isEscape ( e ) || isUp ( e ) || isDown ( e ) || isTabNext ( e ) || isEnter ( e ) || isPageUp ( e ) || isPageDown ( e ) || isHome ( e ) || isEnd ( e ) || isEscape ( e ) ) ;
512477
513- if ( isRight ( e ) ) {
514- this . _handleRight ( e ) ;
515- }
516-
517478 if ( isDown ( e ) ) {
518479 this . _handleDown ( e ) ;
519480 }
@@ -523,15 +484,6 @@ class Search extends SearchField {
523484 }
524485 }
525486
526- _onfocusout ( ) {
527- super . _onfocusout ( ) ;
528- if ( this . _matchedPerTerm ) {
529- this . value = this . _typedInValue ;
530- this . _innerValue = this . _typedInValue ;
531- }
532- this . _matchedPerTerm = false ;
533- }
534-
535487 _onFocusOutSearch ( e :FocusEvent ) {
536488 const target = e . relatedTarget as HTMLElement ;
537489
@@ -587,19 +539,12 @@ class Search extends SearchField {
587539 }
588540
589541 const startsWithMatches = this . _startsWithMatchingItems ( current ) ;
590- const partialMatches = this . _startsWithPerTermMatchingItems ( current ) ;
591542
592543 if ( ! startsWithMatches . length ) {
593- return partialMatches [ 0 ] ?? undefined ;
594- }
595-
596- if ( ! partialMatches . length ) {
597- return startsWithMatches [ 0 ] ;
544+ return undefined ;
598545 }
599546
600- return this . _flattenItems . indexOf ( startsWithMatches [ 0 ] ) <= this . _flattenItems . indexOf ( partialMatches [ 0 ] )
601- ? startsWithMatches [ 0 ]
602- : partialMatches [ 0 ] ;
547+ return startsWithMatches [ 0 ] ;
603548 }
604549
605550 _getPicker ( ) {
0 commit comments