fix: fix bug, AutoComplete, add fault tolerant (#806)
Reviewed-on: daoyoucloud/tachybase#806
This commit is contained in:
parent
a5f2dea973
commit
a7f59c73a7
@ -53,7 +53,7 @@ export const AutoComplete = connect((props) => {
|
||||
<AntdAutoComplete
|
||||
{...props}
|
||||
options={options}
|
||||
filterOption={(inputValue, option) => fuzzysearch(inputValue, option[targetKey].toString())}
|
||||
filterOption={(inputValue, option) => fuzzysearch(inputValue, option[targetKey]?.toString())}
|
||||
allowClear
|
||||
onSearch={onSearch}
|
||||
/>
|
||||
|
@ -1,4 +1,8 @@
|
||||
export function fuzzysearch(needle: string, haystack: string): boolean {
|
||||
if (!needle || !haystack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const hlen = haystack.length;
|
||||
const nlen = needle.length;
|
||||
if (nlen > hlen) {
|
||||
|
Loading…
Reference in New Issue
Block a user