From a7f59c73a7d2d0a3116c3209f83b0ab60ad2c973 Mon Sep 17 00:00:00 2001 From: "bai.zixv" Date: Tue, 23 Apr 2024 11:59:44 +0800 Subject: [PATCH] fix: fix bug, AutoComplete, add fault tolerant (#806) Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/806 --- .../client/schema-components/auto-complete/AutoComplete.tsx | 2 +- packages/plugins/@hera/plugin-core/src/client/utils.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/plugins/@hera/plugin-core/src/client/schema-components/auto-complete/AutoComplete.tsx b/packages/plugins/@hera/plugin-core/src/client/schema-components/auto-complete/AutoComplete.tsx index 4079dcc76..49f492cf3 100644 --- a/packages/plugins/@hera/plugin-core/src/client/schema-components/auto-complete/AutoComplete.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/schema-components/auto-complete/AutoComplete.tsx @@ -53,7 +53,7 @@ export const AutoComplete = connect((props) => { fuzzysearch(inputValue, option[targetKey].toString())} + filterOption={(inputValue, option) => fuzzysearch(inputValue, option[targetKey]?.toString())} allowClear onSearch={onSearch} /> diff --git a/packages/plugins/@hera/plugin-core/src/client/utils.ts b/packages/plugins/@hera/plugin-core/src/client/utils.ts index a12cc5c1b..a9ae4c6bc 100644 --- a/packages/plugins/@hera/plugin-core/src/client/utils.ts +++ b/packages/plugins/@hera/plugin-core/src/client/utils.ts @@ -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) {