Skip to content

Commit c22dfbd

Browse files
Merge pull request #219 from balena-io-modules/fix-automplete
Momentary virtualized autocomplete loadNext fix
2 parents d0a0484 + 03768d3 commit c22dfbd

File tree

1 file changed

+4
-4
lines changed
  • src/components/VirtualizedAutocomplete

1 file changed

+4
-4
lines changed

src/components/VirtualizedAutocomplete/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ const VirtualizedAutocompleteBase = <
241241
[loadNextPage, response.totalItems, response.data, page, query],
242242
);
243243

244+
React.useEffect(() => {
245+
void loadNextPage(0, [], '');
246+
}, []);
247+
244248
return (
245249
<Autocomplete<Value, Multiple, DisableClearable, FreeSolo, ChipComponent>
246250
{...props}
@@ -270,10 +274,6 @@ const VirtualizedAutocompleteBase = <
270274
>['ListboxComponent']
271275
}
272276
onInputChange={async (event, input) => {
273-
// dropdown is opened, we should move this in a useEffect
274-
if (!event && !response.totalItems) {
275-
await loadNextPage(0, [], '');
276-
}
277277
// input change
278278
if (event?.type === 'change') {
279279
await debouncedInputChange(input, []);

0 commit comments

Comments
 (0)