fix: fix bug, AutoComplete, add fault tolerant (#806)

Reviewed-on: daoyoucloud/tachybase#806
This commit is contained in:
bai.zixv 2024-04-23 11:59:44 +08:00
parent a5f2dea973
commit a7f59c73a7
2 changed files with 5 additions and 1 deletions

View File

@ -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}
/> />

View File

@ -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) {