File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ yarn ios
265
265
| ` closeOnSubmit ` | whether to close dropdown on submit | bool | false |
266
266
| ` clearOnFocus ` | whether to clear typed text on focus | bool | true |
267
267
| ` ignoreAccents ` | ignore diacritics | bool | true |
268
+ | ` trimSearchText ` | trim the searched text | bool | true |
268
269
| ` debounce ` | wait ** ms** before call ` onChangeText ` | number | 0 |
269
270
| ` suggestionsListMaxHeight ` | max height of dropdown | number | 200 |
270
271
| ` direction ` | "up" or "down" | string | down + auto calculate |
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ interface AutocompleteDropdownProps {
36
36
closeOnSubmit ?: boolean
37
37
clearOnFocus ?: boolean
38
38
ignoreAccents ?: boolean
39
+ trimSearchText ?: boolean
39
40
matchFrom ?: 'any' | 'start'
40
41
debounce ?: number
41
42
direction ?: 'down' | 'up'
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ export const AutocompleteDropdown = memo(
35
35
const [ dataSet , setDataSet ] = useState ( props . dataSet )
36
36
const clearOnFocus = props . clearOnFocus === false ? false : true
37
37
const ignoreAccents = props . ignoreAccents === false ? false : true
38
+ const trimSearchText = props . trimSearchText === false ? false : true
38
39
const matchFromStart = props . matchFrom === 'start' ? true : false
39
40
const inputHeight = props . inputHeight ?? moderateScale ( 40 , 0.2 )
40
41
const suggestionsListMaxHeight = props . suggestionsListMaxHeight ?? moderateScale ( 200 , 0.2 )
@@ -191,7 +192,15 @@ export const AutocompleteDropdown = memo(
191
192
return
192
193
}
193
194
194
- const findWhat = ignoreAccents ? diacriticless ( searchText . toLowerCase ( ) ) : searchText . toLowerCase ( )
195
+ let findWhat = searchText . toLowerCase ( )
196
+
197
+ if ( ignoreAccents ) {
198
+ findWhat = diacriticless ( findWhat )
199
+ }
200
+
201
+ if ( trimSearchText ) {
202
+ findWhat = findWhat . trim ( )
203
+ }
195
204
196
205
const newSet = props . dataSet . filter ( item => {
197
206
const findWhere = ignoreAccents ? diacriticless ( item . title . toLowerCase ( ) ) : item . title . toLowerCase ( )
You can’t perform that action at this time.
0 commit comments