@@ -18,14 +18,13 @@ import {
18
18
isPageDown ,
19
19
isHome ,
20
20
isEnd ,
21
- isRight ,
22
21
isTabPrevious ,
23
22
} from "@ui5/webcomponents-base/dist/Keys.js" ;
24
23
25
24
import SearchTemplate from "./SearchTemplate.js" ;
26
25
import SearchCss from "./generated/themes/Search.css.js" ;
27
26
import SearchField from "./SearchField.js" ;
28
- import { StartsWith , StartsWithPerTerm } from "@ui5/webcomponents/dist/Filters.js" ;
27
+ import { StartsWith } from "@ui5/webcomponents/dist/Filters.js" ;
29
28
import type UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js" ;
30
29
import type SearchItem from "./SearchItem.js" ;
31
30
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js" ;
@@ -208,12 +207,6 @@ class Search extends SearchField {
208
207
*/
209
208
_valueBeforeOpen : string ;
210
209
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
-
217
210
/**
218
211
* Holds the currently proposed item which will be selected if the user presses Enter.
219
212
* @private
@@ -228,7 +221,6 @@ class Search extends SearchField {
228
221
229
222
// The typed in value.
230
223
this . _typedInValue = "" ;
231
- this . _matchedPerTerm = false ;
232
224
this . _valueBeforeOpen = this . getAttribute ( "value" ) || "" ;
233
225
}
234
226
@@ -317,29 +309,17 @@ class Search extends SearchField {
317
309
318
310
_handleTypeAhead ( item : ISearchSuggestionItem ) {
319
311
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
- }
328
312
329
313
this . _typedInValue = this . value ;
330
- this . _innerValue = displayValue ;
314
+ this . _innerValue = originalValue ;
331
315
this . _performTextSelection = true ;
332
- this . value = displayValue ;
316
+ this . value = originalValue ;
333
317
}
334
318
335
319
_startsWithMatchingItems ( str : string ) : Array < ISearchSuggestionItem > {
336
320
return StartsWith ( str , this . _flattenItems . filter ( item => ! this . _isGroupItem ( item ) && ! this . _isShowMoreItem ( item ) ) , "text" ) ;
337
321
}
338
322
339
- _startsWithPerTermMatchingItems ( str : string ) : Array < ISearchSuggestionItem > {
340
- return StartsWithPerTerm ( str , this . _flattenItems . filter ( item => ! this . _isGroupItem ( item ) && ! this . _isShowMoreItem ( item ) ) , "text" ) ;
341
- }
342
-
343
323
_isGroupItem ( item : HTMLElement ) : item is SearchItemGroup {
344
324
return item . hasAttribute ( "ui5-search-item-group" ) ;
345
325
}
@@ -374,15 +354,6 @@ class Search extends SearchField {
374
354
}
375
355
}
376
356
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
-
386
357
_handleInnerClick ( ) {
387
358
if ( isPhone ( ) ) {
388
359
this . open = true ;
@@ -405,12 +376,6 @@ class Search extends SearchField {
405
376
}
406
377
407
378
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
- }
414
379
415
380
innerInput . setSelectionRange ( this . value . length , this . value . length ) ;
416
381
this . open = false ;
@@ -510,10 +475,6 @@ class Search extends SearchField {
510
475
this . _shouldAutocomplete = ! this . noTypeahead
511
476
&& ! ( isBackSpace ( e ) || isDelete ( e ) || isEscape ( e ) || isUp ( e ) || isDown ( e ) || isTabNext ( e ) || isEnter ( e ) || isPageUp ( e ) || isPageDown ( e ) || isHome ( e ) || isEnd ( e ) || isEscape ( e ) ) ;
512
477
513
- if ( isRight ( e ) ) {
514
- this . _handleRight ( e ) ;
515
- }
516
-
517
478
if ( isDown ( e ) ) {
518
479
this . _handleDown ( e ) ;
519
480
}
@@ -523,15 +484,6 @@ class Search extends SearchField {
523
484
}
524
485
}
525
486
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
-
535
487
_onFocusOutSearch ( e :FocusEvent ) {
536
488
const target = e . relatedTarget as HTMLElement ;
537
489
@@ -587,19 +539,12 @@ class Search extends SearchField {
587
539
}
588
540
589
541
const startsWithMatches = this . _startsWithMatchingItems ( current ) ;
590
- const partialMatches = this . _startsWithPerTermMatchingItems ( current ) ;
591
542
592
543
if ( ! startsWithMatches . length ) {
593
- return partialMatches [ 0 ] ?? undefined ;
594
- }
595
-
596
- if ( ! partialMatches . length ) {
597
- return startsWithMatches [ 0 ] ;
544
+ return undefined ;
598
545
}
599
546
600
- return this . _flattenItems . indexOf ( startsWithMatches [ 0 ] ) <= this . _flattenItems . indexOf ( partialMatches [ 0 ] )
601
- ? startsWithMatches [ 0 ]
602
- : partialMatches [ 0 ] ;
547
+ return startsWithMatches [ 0 ] ;
603
548
}
604
549
605
550
_getPicker ( ) {
0 commit comments