From 3723ad1486ed90f029d0de67265248916628eeb4 Mon Sep 17 00:00:00 2001 From: wjh Date: Fri, 10 May 2024 11:49:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=9A=E5=AF=B9?= =?UTF-8?q?=E5=A4=9A=E7=AD=9B=E9=80=89=E4=B8=AD=E9=97=B4=E8=A1=A8=E6=97=A0?= =?UTF-8?q?=E6=95=88=20(#962)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/962 Reviewed-by: sealday Co-authored-by: wjh Co-committed-by: wjh --- .../collection-manager/Configuration/components/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/components/index.tsx b/packages/core/client/src/collection-manager/Configuration/components/index.tsx index 1137fa2d3..77e5e0765 100644 --- a/packages/core/client/src/collection-manager/Configuration/components/index.tsx +++ b/packages/core/client/src/collection-manager/Configuration/components/index.tsx @@ -303,6 +303,7 @@ export const ThroughCollection = observer( const record = useRecord(); const value = record[field.props.name]; const [initialValue, setInitialValue] = useState(value || field.initialValue); + const [defOptions, setDefOptions] = useState([]); const loadCollections = () => { const filteredItems = getCollections().filter((item) => { @@ -320,6 +321,7 @@ export const ThroughCollection = observer( useEffect(() => { const data = loadCollections(); setOptions(data); + setDefOptions(data); if (value) { const option = data.find((v) => v.value === value); setInitialValue(option?.label || value); @@ -327,13 +329,13 @@ export const ThroughCollection = observer( }, []); const handleSearch = (value: string) => { if (value) { - const filteredOptions = options.filter((option) => { + const filteredOptions = defOptions.filter((option) => { return option.label.toLowerCase().includes(value.toLowerCase()); }); + setOptions(filteredOptions); } else { - const data = loadCollections(); - setOptions(data); + setOptions(defOptions); } }; return (