Skip to content

Commit

Permalink
fix: no correct reset state (#7191)
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsweet committed Mar 19, 2024
1 parent 3274ad0 commit cb69f35
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)}
Expand Down

0 comments on commit cb69f35

Please sign in to comment.