From 411eb79cdfaedad9361ee4d6e5fed3dfb946627f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=92=E6=B9=9B?= <0x1304570@gmail.com> Date: Tue, 19 Mar 2024 21:10:50 +1300 Subject: [PATCH] fix: no correct reset state (#7191) --- .../plugins/components/data-scope-remote/search-remote.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config-ui/src/plugins/components/data-scope-remote/search-remote.tsx b/config-ui/src/plugins/components/data-scope-remote/search-remote.tsx index 60913a7d05f..f49a102445d 100644 --- a/config-ui/src/plugins/components/data-scope-remote/search-remote.tsx +++ b/config-ui/src/plugins/components/data-scope-remote/search-remote.tsx @@ -53,12 +53,14 @@ export const SearchRemote = ({ plugin, connectionId, config, disabledScope, sele }); const [search, setSearch] = useState<{ + loading: boolean; items: McsItem[]; currentItems: McsItem[]; query: string; page: number; total: number; }>({ + loading: true, items: [], currentItems: [], query: '', @@ -138,6 +140,7 @@ export const SearchRemote = ({ plugin, connectionId, config, disabledScope, sele setSearch((s) => ({ ...s, + loading: false, items: [...allItems, ...newItems], currentItems: newItems, total: res.count, @@ -173,7 +176,7 @@ export const SearchRemote = ({ plugin, connectionId, config, disabledScope, sele prefix={} placeholder={config.searchPlaceholder ?? 'Search'} value={search.query} - onChange={(e) => setSearch({ ...search, query: e.target.value })} + onChange={(e) => setSearch({ ...search, query: e.target.value, loading: true, currentItems: [] })} /> {!searchDebounce ? ( false} - getHasMore={() => search.total === 0} + getHasMore={() => search.loading} onScroll={() => setSearch({ ...search, page: search.page + 1 })} renderLoading={() => } disabledIds={(disabledScope ?? []).map((it) => it.id)}