@@ -13,13 +13,14 @@ let _defaults = {
13
13
} ,
14
14
minLength : 1 , // Min characters before autocomplete starts
15
15
isMultiSelect : false ,
16
- onSearch : function ( text , autocomplete ) {
17
- const filteredData = autocomplete . options . data . filter ( item => {
18
- return Object . keys ( item )
19
- . map ( key => item [ key ] . toString ( ) . toLowerCase ( ) . indexOf ( text . toLowerCase ( ) ) >= 0 )
20
- . some ( isMatch => isMatch ) ;
21
- } ) ;
22
- autocomplete . setMenuItems ( filteredData ) ;
16
+ onSearch : ( text : string , autocomplete ) => {
17
+ const normSearch = text . toLocaleLowerCase ( ) ;
18
+ autocomplete . setMenuItems (
19
+ autocomplete . options . data . filter ( ( option ) =>
20
+ option . id . toString ( ) . toLocaleLowerCase ( ) . includes ( normSearch )
21
+ || option . text ?. toLocaleLowerCase ( ) . includes ( normSearch )
22
+ )
23
+ ) ;
23
24
} ,
24
25
maxDropDownHeight : '300px' ,
25
26
allowUnsafeHTML : false
@@ -175,7 +176,7 @@ export class Autocomplete extends Component {
175
176
_handleInputKeyupAndFocus = ( e : KeyboardEvent ) => {
176
177
if ( e . type === 'keyup' ) Autocomplete . _keydown = false ;
177
178
this . count = 0 ;
178
- const actualValue = this . el . value . toLowerCase ( ) ;
179
+ const actualValue = this . el . value . toLocaleLowerCase ( ) ;
179
180
// Don't capture enter or arrow key usage.
180
181
if ( M . keys . ENTER . includes ( e . key ) || M . keys . ARROW_UP . includes ( e . key ) || M . keys . ARROW_DOWN . includes ( e . key ) ) return ;
181
182
// Check if the input isn't empty
@@ -254,7 +255,7 @@ export class Autocomplete extends Component {
254
255
}
255
256
256
257
_highlightPartialText ( input , label ) {
257
- const start = label . toLowerCase ( ) . indexOf ( '' + input . toLowerCase ( ) + '' ) ;
258
+ const start = label . toLocaleLowerCase ( ) . indexOf ( '' + input . toLocaleLowerCase ( ) + '' ) ;
258
259
const end = start + input . length - 1 ;
259
260
//custom filters may return results where the string does not match any part
260
261
if ( start == - 1 || end == - 1 ) {
@@ -288,7 +289,7 @@ export class Autocomplete extends Component {
288
289
}
289
290
290
291
// Text
291
- const inputText = this . el . value . toLowerCase ( ) ;
292
+ const inputText = this . el . value . toLocaleLowerCase ( ) ;
292
293
const parts = this . _highlightPartialText ( inputText , ( entry . text || entry . id ) . toString ( ) ) ;
293
294
const div = document . createElement ( 'div' ) ;
294
295
div . setAttribute ( 'style' , 'line-height:1.2;font-weight:500;' ) ;
@@ -378,7 +379,7 @@ export class Autocomplete extends Component {
378
379
}
379
380
380
381
open ( ) {
381
- const inputText = this . el . value . toLowerCase ( ) ;
382
+ const inputText = this . el . value . toLocaleLowerCase ( ) ;
382
383
this . _resetAutocomplete ( ) ;
383
384
if ( inputText . length >= this . options . minLength ) {
384
385
this . isOpen = true ;
0 commit comments