i-like-robots / react-tag-autocomplete

⚛️ A simple, accessible, tagging component ready to drop into your React projects (new repo)
https://i-like-robots.github.io/react-tag-autocomplete/
ISC License
178 stars 12 forks source link

Broken "Async suggestions" demo #7

Closed Tomas2D closed 2 years ago

Tomas2D commented 2 years ago

The Loading.... message never shows up, tried also on my project and it looks like that the changed prop does not trigger component re-render.

const noOptionsText =
    state.isBusy && !state.suggestions.length ? 'Loading...' : 'No breweries found'`

https://i-like-robots.github.io/react-tag-autocomplete/

Thanks

Tomas2D commented 2 years ago

I find out a workaround by adding disabled option with the text Loading. It works, but there is a problem that the newOption is by default at the end of the list. I think that we should have an option to choose the newOption position, it should be either start on end. What do you think?

i-like-robots commented 2 years ago

Thanks for the report and for your suggestions. I've had a look into this now and I can see that the newTagOption and noTagsOption methods are not being updated within the main manager state (along with some of this). I can make changes to fix this but I've always felt the internal options had quite a crude solution that I've never been happy with so I'll have a think how this may be better implemented.

i-like-robots commented 2 years ago

I've merged a refactor of the state manager to avoid copying props into state and derive values for options on the fly. This resolves the bug reported but the demo could still be improved in a number of ways.