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
|
<AntdAutoComplete
|
||||||
{...props}
|
{...props}
|
||||||
options={options}
|
options={options}
|
||||||
filterOption={(inputValue, option) => fuzzysearch(inputValue, option[targetKey].toString())}
|
filterOption={(inputValue, option) => fuzzysearch(inputValue, option[targetKey]?.toString())}
|
||||||
allowClear
|
allowClear
|
||||||
onSearch={onSearch}
|
onSearch={onSearch}
|
||||||
/>
|
/>
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
export function fuzzysearch(needle: string, haystack: string): boolean {
|
export function fuzzysearch(needle: string, haystack: string): boolean {
|
||||||
|
if (!needle || !haystack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const hlen = haystack.length;
|
const hlen = haystack.length;
|
||||||
const nlen = needle.length;
|
const nlen = needle.length;
|
||||||
if (nlen > hlen) {
|
if (nlen > hlen) {
|
||||||
|
Loading…
Reference in New Issue
Block a user