You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by gi...@apache.org on 2024/03/19 08:11:12 UTC

(incubator-devlake) 01/01: fix: no correct reset state (#7191)

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch release-v0.21-auto-cherry-pick-7191
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 411eb79cdfaedad9361ee4d6e5fed3dfb946627f
Author: 青湛 <0x...@gmail.com>
AuthorDate: Tue Mar 19 21:10:50 2024 +1300

    fix: no correct reset state (#7191)
---
 .../src/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 60913a7d0..f49a10244 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<T.ResItem>[];
     currentItems: McsItem<T.ResItem>[];
     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={<SearchOutlined />}
           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 ? (
           <MillerColumnsSelect
@@ -203,7 +206,7 @@ export const SearchRemote = ({ plugin, connectionId, config, disabledScope, sele
             columnCount={1}
             columnHeight={300}
             getCanExpand={() => false}
-            getHasMore={() => search.total === 0}
+            getHasMore={() => search.loading}
             onScroll={() => setSearch({ ...search, page: search.page + 1 })}
             renderLoading={() => <Loading size={20} style={{ padding: '4px 12px' }} />}
             disabledIds={(disabledScope ?? []).map((it) => it.id)}