Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async Autocomplete component triggers a search call for every initial value #178

Open
rvanlaarhoven opened this issue Nov 17, 2020 · 0 comments

Comments

@rvanlaarhoven
Copy link
Contributor

rvanlaarhoven commented Nov 17, 2020

When you have an Autocomplete component with asyncItems={handleSearch} and multipleSelect={true} it will trigger a search call for each item on mount that you define as defaultValue. Instead, it should just trigger 1 search call without a search parameter on mount or at least should be possible to skip this data fetching on mount.

Caused by:

https://github.com/digipolisantwerp/acpaas-ui_react/blob/5543d9a35a10e31569fa96497f4a7e8954aeacbe/packages/autocomplete/src/models/AsyncSearchMode.js#L13

To reproduce:

<Autocomplete
  asyncItems={(search) => console.log(`Searching for ${search}`}
  multiSelect={true}
  defaultValue={['item1', 'item2', 'item3']}
/>

The above example will result in three api calls with those values as search parameter and there's no way to prevent this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant