Skip to content

Commit

Permalink
fix: loading: disable loading correctly
Browse files Browse the repository at this point in the history
short circuit logic when a request comes back prevented the loading
spinner from being hidden
  • Loading branch information
mxlje committed Jul 20, 2021
1 parent 5236af3 commit 35cb225
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/autocomplete/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ export default ({
// search queries the autocomplete API
const search = useCallback(text => {
autocomplete(text).then(({ features, discard }) => {
setIsLoading(false)

if (discard || inputRef.current.value !== text) {
return
}

setIsLoading(false)
setResults({ text, features })
openMenu()
})
Expand Down

0 comments on commit 35cb225

Please sign in to comment.