Taglist adds duplicate options when loaded from an API
See original GitHub issueReproduction
https://formkit.link/1439704f7483844193e5b340a36a0caf
Describe the bug
I’m loading options for the taglist component via an API call instead of assigning them directly.
The sample code of the Loading options section in the documentation returns an empty array when no search query is provided:
if (!search) return [];
For my use case, I always want to return a list of options, even if no query has been provided (yet).
When clicking on the taglist input to open the option list, this works fine the first time. But when clicking away to close the options list (without typing or selecting anything) the taglist executes a ‘search’ request on close and appends the results to the existing options. Effectively duplicating the options list every time the input is closed.
I’ve provided an example in the reproduction link. Simply click on the input field (one option will show), click away, and click again (option is duplicated). More duplicate options are added every time you repeat this step.
Environment
• OS: [e.g. iOS] • Browser [e.g. chrome, safari] • Version [e.g. 22]
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
@sashamilenkovic Working! 👍
@jerrebm Perfect!