Skip to content

Commit 85d8c14

Browse files
fix: no correct reset state (#7191) (#7192)
Co-authored-by: 青湛 <0x1304570@gmail.com>
1 parent b7a1728 commit 85d8c14

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

config-ui/src/plugins/components/data-scope-remote/search-remote.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ export const SearchRemote = ({ plugin, connectionId, config, disabledScope, sele
5353
});
5454

5555
const [search, setSearch] = useState<{
56+
loading: boolean;
5657
items: McsItem<T.ResItem>[];
5758
currentItems: McsItem<T.ResItem>[];
5859
query: string;
5960
page: number;
6061
total: number;
6162
}>({
63+
loading: true,
6264
items: [],
6365
currentItems: [],
6466
query: '',
@@ -138,6 +140,7 @@ export const SearchRemote = ({ plugin, connectionId, config, disabledScope, sele
138140

139141
setSearch((s) => ({
140142
...s,
143+
loading: false,
141144
items: [...allItems, ...newItems],
142145
currentItems: newItems,
143146
total: res.count,
@@ -173,7 +176,7 @@ export const SearchRemote = ({ plugin, connectionId, config, disabledScope, sele
173176
prefix={<SearchOutlined />}
174177
placeholder={config.searchPlaceholder ?? 'Search'}
175178
value={search.query}
176-
onChange={(e) => setSearch({ ...search, query: e.target.value })}
179+
onChange={(e) => setSearch({ ...search, query: e.target.value, loading: true, currentItems: [] })}
177180
/>
178181
{!searchDebounce ? (
179182
<MillerColumnsSelect
@@ -203,7 +206,7 @@ export const SearchRemote = ({ plugin, connectionId, config, disabledScope, sele
203206
columnCount={1}
204207
columnHeight={300}
205208
getCanExpand={() => false}
206-
getHasMore={() => search.total === 0}
209+
getHasMore={() => search.loading}
207210
onScroll={() => setSearch({ ...search, page: search.page + 1 })}
208211
renderLoading={() => <Loading size={20} style={{ padding: '4px 12px' }} />}
209212
disabledIds={(disabledScope ?? []).map((it) => it.id)}

0 commit comments

Comments
 (0)